1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:38:11 +00:00

AK+Format: Add outln(FILE*, ...) overload.

This commit also removes a few functions like raw_out and vwarn. If we
want to write raw output, we can do this as follows:

    out("{}", "Hello, World!");

The vout stuff isn't really public API anyways, so no need for another
vwarn.
This commit is contained in:
asynts 2020-10-15 13:46:00 +02:00 committed by Andreas Kling
parent a274a8e5a0
commit 0508fdbbcd
3 changed files with 49 additions and 44 deletions

View file

@ -214,4 +214,25 @@ TEST_CASE(format_if_supported)
EXPECT_EQ(String::formatted("{}", FormatIfSupported { B {} }), "B");
}
TEST_CASE(file_descriptor)
{
char filename[] = "/tmp/test-file-descriptor-XXXXXX";
int fd = mkstemp(filename);
FILE* file = fdopen(fd, "w+");
outln(file, "{}", "Hello, World!");
new_out(file, "foo");
outln(file, "bar");
rewind(file);
Array<u8, 256> buffer;
const auto nread = fread(buffer.data(), 1, buffer.size(), file);
EXPECT_EQ(StringView { "Hello, World!\nfoobar\n" }, StringView { buffer.span().trim(nread) });
fclose(file);
}
TEST_MAIN(Format)