* make conv::char32_to_utf8_unsafe() return the number of bytes it wrote
add tests for DString
fix pointer arithmetic in DString.insert_at

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>

* add support to printf for %d and enums

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>

---------

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
Pierre Curto
2023-10-08 02:12:20 +02:00
committed by GitHub
parent 312a39ee24
commit 3aa85cf641
5 changed files with 163 additions and 13 deletions

View File

@@ -50,4 +50,25 @@ fn void printf_a()
String ss = "hello world";
s = string::printf("%.4s %.5s", ss, ss);
assert(s == "hell hello", "got '%s'; want 'hell hello'", s);
}
enum PrintfTest : ushort
{
ENUMA,
ENUMB,
}
fn void printf_enum()
{
String s;
s = string::printf("%s", PrintfTest.ENUMA);
assert(s == "ENUMA", "got '%s'; want 'ENUMA'", s);
s = string::printf("%s", PrintfTest.ENUMB);
assert(s == "ENUMB", "got '%s'; want 'ENUMB'", s);
s = string::printf("%d", PrintfTest.ENUMA);
assert(s == "0", "got '%s'; want '0'", s);
s = string::printf("%d", PrintfTest.ENUMB);
assert(s == "1", "got '%s'; want '1'", s);
}