| ... | @@ -2111,6 +2111,7 @@ test "slice" { | ... | @@ -2111,6 +2111,7 @@ test "slice" { |
| 2111 | } | 2111 | } |
| 2112 | | 2112 | |
| 2113 | test "escape non-printable" { | 2113 | test "escape non-printable" { |
| | 2114 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; |
| 2114 | try expectFmt("abc", "{s}", .{fmtSliceEscapeLower("abc")}); | 2115 | try expectFmt("abc", "{s}", .{fmtSliceEscapeLower("abc")}); |
| 2115 | try expectFmt("ab\\xffc", "{s}", .{fmtSliceEscapeLower("ab\xffc")}); | 2116 | try expectFmt("ab\\xffc", "{s}", .{fmtSliceEscapeLower("ab\xffc")}); |
| 2116 | try expectFmt("ab\\xFFc", "{s}", .{fmtSliceEscapeUpper("ab\xffc")}); | 2117 | try expectFmt("ab\\xFFc", "{s}", .{fmtSliceEscapeUpper("ab\xffc")}); |
| ... | @@ -2146,6 +2147,7 @@ test "cstr" { | ... | @@ -2146,6 +2147,7 @@ test "cstr" { |
| 2146 | } | 2147 | } |
| 2147 | | 2148 | |
| 2148 | test "filesize" { | 2149 | test "filesize" { |
| | 2150 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; |
| 2149 | try expectFmt("file size: 42B\n", "file size: {}\n", .{fmtIntSizeDec(42)}); | 2151 | try expectFmt("file size: 42B\n", "file size: {}\n", .{fmtIntSizeDec(42)}); |
| 2150 | try expectFmt("file size: 42B\n", "file size: {}\n", .{fmtIntSizeBin(42)}); | 2152 | try expectFmt("file size: 42B\n", "file size: {}\n", .{fmtIntSizeBin(42)}); |
| 2151 | try expectFmt("file size: 63MB\n", "file size: {}\n", .{fmtIntSizeDec(63 * 1000 * 1000)}); | 2153 | try expectFmt("file size: 63MB\n", "file size: {}\n", .{fmtIntSizeDec(63 * 1000 * 1000)}); |
| ... | @@ -2445,6 +2447,7 @@ test "struct.zero-size" { | ... | @@ -2445,6 +2447,7 @@ test "struct.zero-size" { |
| 2445 | } | 2447 | } |
| 2446 | | 2448 | |
| 2447 | test "bytes.hex" { | 2449 | test "bytes.hex" { |
| | 2450 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; |
| 2448 | const some_bytes = "\xCA\xFE\xBA\xBE"; | 2451 | const some_bytes = "\xCA\xFE\xBA\xBE"; |
| 2449 | try expectFmt("lowercase: cafebabe\n", "lowercase: {x}\n", .{fmtSliceHexLower(some_bytes)}); | 2452 | try expectFmt("lowercase: cafebabe\n", "lowercase: {x}\n", .{fmtSliceHexLower(some_bytes)}); |
| 2450 | try expectFmt("uppercase: CAFEBABE\n", "uppercase: {X}\n", .{fmtSliceHexUpper(some_bytes)}); | 2453 | try expectFmt("uppercase: CAFEBABE\n", "uppercase: {X}\n", .{fmtSliceHexUpper(some_bytes)}); |
| ... | @@ -2476,6 +2479,7 @@ pub fn hexToBytes(out: []u8, input: []const u8) ![]u8 { | ... | @@ -2476,6 +2479,7 @@ pub fn hexToBytes(out: []u8, input: []const u8) ![]u8 { |
| 2476 | } | 2479 | } |
| 2477 | | 2480 | |
| 2478 | test "hexToBytes" { | 2481 | test "hexToBytes" { |
| | 2482 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; |
| 2479 | var buf: [32]u8 = undefined; | 2483 | var buf: [32]u8 = undefined; |
| 2480 | try expectFmt("90" ** 32, "{s}", .{fmtSliceHexUpper(try hexToBytes(&buf, "90" ** 32))}); | 2484 | try expectFmt("90" ** 32, "{s}", .{fmtSliceHexUpper(try hexToBytes(&buf, "90" ** 32))}); |
| 2481 | try expectFmt("ABCD", "{s}", .{fmtSliceHexUpper(try hexToBytes(&buf, "ABCD"))}); | 2485 | try expectFmt("ABCD", "{s}", .{fmtSliceHexUpper(try hexToBytes(&buf, "ABCD"))}); |