| ... | ... | @@ -227,7 +227,7 @@ pub fn formatIntValue(value: var, comptime fmt: []const u8, context: var, compti |
| 227 | 227 | 'c' => { |
| 228 | 228 | if(@typeOf(value) == u8) { |
| 229 | 229 | if(fmt.len > 1) @compileError("Unknown format character: " ++ []u8{fmt[1]}); |
| 230 | | return formatAsciiChar(fmt[0], context, Errors, output); |
| 230 | return formatAsciiChar(value, context, Errors, output); |
| 231 | 231 | } |
| 232 | 232 | }, |
| 233 | 233 | 'd' => { |
| ... | ... | @@ -810,6 +810,10 @@ test "fmt.format" { |
| 810 | 810 | const value: u3 = 0b101; |
| 811 | 811 | try testFmt("u3: 5\n", "u3: {}\n", value); |
| 812 | 812 | } |
| 813 | { |
| 814 | const value: u8 = 'a'; |
| 815 | try testFmt("u8: a\n", "u8: {c}\n", value); |
| 816 | } |
| 813 | 817 | try testFmt("file size: 63MiB\n", "file size: {Bi}\n", usize(63 * 1024 * 1024)); |
| 814 | 818 | try testFmt("file size: 66.06MB\n", "file size: {B2}\n", usize(63 * 1024 * 1024)); |
| 815 | 819 | { |
| ... | ... | @@ -1054,10 +1058,8 @@ test "fmt.format" { |
| 1054 | 1058 | |
| 1055 | 1059 | var buf1: [32]u8 = undefined; |
| 1056 | 1060 | var value = Vec2{.x = 10.2, .y = 2.22,}; |
| 1057 | | const point_result = try bufPrint(buf1[0..], "point: {}\n", &value); |
| 1058 | | assert(mem.eql(u8, point_result, "point: (10.200,2.220)\n")); |
| 1059 | | const dim_result = try bufPrint(buf1[0..], "dim: {d}\n", &value); |
| 1060 | | assert(mem.eql(u8, dim_result, "dim: 10.200x2.220\n")); |
| 1061 | try testFmt("point: (10.200,2.220)\n", "point: {}\n", &value); |
| 1062 | try testFmt("dim: 10.200x2.220\n", "dim: {d}\n", &value); |
| 1061 | 1063 | } |
| 1062 | 1064 | } |
| 1063 | 1065 | |