diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-05-07 23:25:02 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-05-07 23:25:02 -0400 |
| commit | 8abcd94eceef08402f86c774c0f484cb51c6905a (patch) | |
| tree | 7a14224995e21d9db00731c778a6ccc9ef8e7413 /std | |
| parent | 5774b48ceb7cdca7fbf3dd19fff4a0e42228473f (diff) | |
| download | zig-8abcd94eceef08402f86c774c0f484cb51c6905a.tar.gz zig-8abcd94eceef08402f86c774c0f484cb51c6905a.zip | |
std.fmt.format prints bool values
Diffstat (limited to 'std')
| -rw-r--r-- | std/fmt.zig | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/std/fmt.zig b/std/fmt.zig index 80ca4af778..d1b91b15f8 100644 --- a/std/fmt.zig +++ b/std/fmt.zig @@ -183,6 +183,8 @@ pub fn formatValue(value: var, context: var, output: fn(@typeOf(context), []cons return output(context, casted_value); } else if (T == void) { return output(context, "void"); + } else if (T == bool) { + return output(context, if (value) "true" else "false"); } else { @compileError("Unable to format type '" ++ @typeName(T) ++ "'"); } @@ -363,7 +365,7 @@ fn countSize(size: &usize, bytes: []const u8) -> bool { return true; } -test "testBufPrintInt" { +test "buf print int" { var buffer: [max_int_digits]u8 = undefined; const buf = buffer[0...]; assert(mem.eql(u8, bufPrintIntToSlice(buf, i32(-12345678), 2, false, 0), "-101111000110000101001110")); @@ -385,7 +387,7 @@ fn bufPrintIntToSlice(buf: []u8, value: var, base: u8, uppercase: bool, width: u return buf[0...formatIntBuf(buf, value, base, uppercase, width)]; } -test "testParseU64DigitTooBig" { +test "parse u64 digit too big" { _ = parseUnsigned(u64, "123a", 10) %% |err| { if (err == error.InvalidChar) return; unreachable; @@ -393,7 +395,7 @@ test "testParseU64DigitTooBig" { unreachable; } -test "testParseUnsignedComptime" { +test "parse unsigned comptime" { comptime { assert(%%parseUnsigned(usize, "2", 10) == 2); } |
