mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
misc (#1033)
* 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:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user