| author | |
| committer | |
| log | da4acf9a485bf1658194c8cb8593dd142677138d |
| tree | 0588fca38068dcc6a366150e6105dc23170b7cda |
| parent | 2e60d4d06400eef07ff05d5552b69961fa9e63f9 |
3 files changed, 19 insertions(+), 1 deletions(-)
lib/std/fmt.zig+4| ... | ... | @@ -784,6 +784,10 @@ fn formatFloatValue( |
| 784 | 784 | } |
| 785 | 785 | } |
| 786 | 786 | |
| 787 | test { | |
| 788 | _ = &ryu128; | |
| 789 | } | |
| 790 | ||
| 787 | 791 | pub const Case = enum { lower, upper }; |
| 788 | 792 | |
| 789 | 793 | fn formatSliceHexImpl(comptime case: Case) type { |
lib/std/fmt/ryu128.zig+14| ... | ... | @@ -959,9 +959,23 @@ const POW5_INV_ERRORS: [154]u64 = .{ |
| 959 | 959 | // zig fmt: on |
| 960 | 960 | |
| 961 | 961 | fn check(comptime T: type, value: T, comptime expected: []const u8) !void { |
| 962 | const I = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } }); | |
| 963 | ||
| 962 | 964 | var buf: [6000]u8 = undefined; |
| 965 | const value_bits: I = @bitCast(value); | |
| 963 | 966 | const s = try format(&buf, value, .{}); |
| 964 | 967 | try std.testing.expectEqualStrings(expected, s); |
| 968 | ||
| 969 | if (@bitSizeOf(T) != 80) { | |
| 970 | const o = try std.fmt.parseFloat(T, s); | |
| 971 | const o_bits: I = @bitCast(o); | |
| 972 | ||
| 973 | if (std.math.isNan(value)) { | |
| 974 | try std.testing.expect(std.math.isNan(o)); | |
| 975 | } else { | |
| 976 | try std.testing.expectEqual(value_bits, o_bits); | |
| 977 | } | |
| 978 | } | |
| 965 | 979 | } |
| 966 | 980 | |
| 967 | 981 | test "format f32" { |
test/cases/safety/slice sentinel mismatch - floats.zig	+1-1| ... | ... | @@ -2,7 +2,7 @@ const std = @import("std"); |
| 2 | 2 | |
| 3 | 3 | pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { |
| 4 | 4 | _ = stack_trace; |
| 5 | if (std.mem.eql(u8, message, "sentinel mismatch: expected 1.20000004e+00, found 4.0e+00")) { | |
| 5 | if (std.mem.eql(u8, message, "sentinel mismatch: expected 1.2e0, found 4e0")) { | |
| 6 | 6 | std.process.exit(0); |
| 7 | 7 | } |
| 8 | 8 | std.process.exit(1); |