Fix tests for Uuid
This commit is contained in:
parent
bca6a98889
commit
f56782a323
1 changed files with 8 additions and 8 deletions
16
src/util.zig
16
src/util.zig
|
@ -103,16 +103,15 @@ test "parse uuid" {
|
|||
}
|
||||
|
||||
test "format uuid" {
|
||||
var buf = [1]u8{0} ** 36;
|
||||
var fbs = std.io.fixedBufferStream(&buf);
|
||||
try Uuid.format(Uuid.Nil, "", .{}, fbs.writer());
|
||||
try std.testing.expectEqualStrings("00000000-0000-0000-0000-000000000000", &buf);
|
||||
try std.testing.expectFmt("00000000-0000-0000-0000-000000000000", "{}", .{Uuid.Nil});
|
||||
|
||||
fbs.reset();
|
||||
try Uuid.format(Uuid{
|
||||
const uuid = Uuid{
|
||||
.data = @bitCast([16]u8, @as(u128, 0x4ba7b74522ad_1da8_c242_d312_60515ff7)),
|
||||
}, "", .{}, fbs.writer());
|
||||
try std.testing.expectEqualStrings("f75f5160-12d3-42c2-a81d-ad2245b7a74b", &buf);
|
||||
};
|
||||
try std.testing.expectFmt("f75f5160-12d3-42c2-a81d-ad2245b7a74b", "{}", .{uuid});
|
||||
|
||||
try std.testing.expectError(error.InvalidCharacter, Uuid.parse("fsdfs"));
|
||||
try std.testing.expectError(error.InvalidCharacter, Uuid.parse("00000000-0000-0000-xxxx-000000000000"));
|
||||
}
|
||||
|
||||
test "roundtrip random uuid" {
|
||||
|
@ -126,6 +125,7 @@ test "roundtrip random uuid" {
|
|||
|
||||
try std.testing.expectEqual(uuid, parsed);
|
||||
}
|
||||
|
||||
pub const ciutf8 = struct {
|
||||
const Hash = std.hash.Wyhash;
|
||||
const View = std.unicode.Utf8View;
|
||||
|
|
Loading…
Reference in a new issue