authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-05-07 23:25:02-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-05-07 23:25:02-04:00
log8abcd94eceef08402f86c774c0f484cb51c6905a
tree7a14224995e21d9db00731c778a6ccc9ef8e7413
parent5774b48ceb7cdca7fbf3dd19fff4a0e42228473f

std.fmt.format prints bool values


1 files changed, 5 insertions(+), 3 deletions(-)

std/fmt.zig+5-3
......@@ -183,6 +183,8 @@ pub fn formatValue(value: var, context: var, output: fn(@typeOf(context), []cons
183183 return output(context, casted_value);
184184 } else if (T == void) {
185185 return output(context, "void");
186 } else if (T == bool) {
187 return output(context, if (value) "true" else "false");
186188 } else {
187189 @compileError("Unable to format type '" ++ @typeName(T) ++ "'");
188190 }
......@@ -363,7 +365,7 @@ fn countSize(size: &usize, bytes: []const u8) -> bool {
363365 return true;
364366}
365367
366test "testBufPrintInt" {
368test "buf print int" {
367369 var buffer: [max_int_digits]u8 = undefined;
368370 const buf = buffer[0...];
369371 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
385387 return buf[0...formatIntBuf(buf, value, base, uppercase, width)];
386388}
387389
388test "testParseU64DigitTooBig" {
390test "parse u64 digit too big" {
389391 _ = parseUnsigned(u64, "123a", 10) %% |err| {
390392 if (err == error.InvalidChar) return;
391393 unreachable;
......@@ -393,7 +395,7 @@ test "testParseU64DigitTooBig" {
393395 unreachable;
394396}
395397
396test "testParseUnsignedComptime" {
398test "parse unsigned comptime" {
397399 comptime {
398400 assert(%%parseUnsigned(usize, "2", 10) == 2);
399401 }