Skip to content

Commit

Permalink
std/fmt/index.zig: ziglang#1358: test bytes printed-out as hex;
Browse files Browse the repository at this point in the history
  • Loading branch information
kristate committed Sep 1, 2018
1 parent 454b236 commit 7a633f4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions std/fmt/index.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,12 @@ test "fmt.format" {

try testFmt("E.Two", "{}", inst);
}
//print bytes as hex
{
const some_bytes = "\xCA\xFE\xBA\xBE";
try testFmt("lowercase: cafebabe\n", "lowercase: {x}\n", some_bytes);
try testFmt("uppercase: CAFEBABE\n", "uppercase: {X}\n", some_bytes);
}
}

fn testFmt(expected: []const u8, comptime template: []const u8, args: ...) !void {
Expand Down

0 comments on commit 7a633f4

Please sign in to comment.