Files
c3c/test/unit/stdlib/io/printf.c3
Pierre Curto 7a39933c97 add NanoDuration.to_format() (#935)
* lib/std/time: avoid switch in DateTime.compare_to()
* lib/std/time: add NanoDuration.to_format()
* std/lib: fix #934
2023-08-17 10:30:20 +02:00

20 lines
846 B
C

module std::io @test;
fn void printf_a()
{
String s;
s = string::printf("%08.2a", 234.125);
assert(s == "0x1.d4p+7", "got '%s'; want '0x1.d4p+7'", s);
s = string::printf("%a", 234.125);
assert(s == "0x1.d44p+7", "got '%s'; want '0x1.d44p+7'", s);
s = string::printf("%A", 234.125);
assert(s == "0X1.D44P+7", "got '%s'; want '0X1.D44P+7'", s);
s = string::printf("%20a", 234.125);
assert(s == " 0x1.d44p+7", "got '%s'; want ' 0x1.d44p+7'", s);
s = string::printf("%-20a", 234.125);
assert(s == "0x1.d44p+7 ", "got '%s'; want '0x1.d44p+7 '", s);
s = string::printf("%-20s", "hello world");
assert(s == "hello world ", "got '%s'; want 'hello world '", s);
s = string::printf("%20s", "hello world");
assert(s == " hello world", "got '%s'; want ' hello world'", s);
}