aboutsummaryrefslogtreecommitdiff
path: root/lib/std/unicode.zig
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/unicode.zig')
-rw-r--r--lib/std/unicode.zig18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/std/unicode.zig b/lib/std/unicode.zig
index 3d16748447..77783c3edd 100644
--- a/lib/std/unicode.zig
+++ b/lib/std/unicode.zig
@@ -501,14 +501,16 @@ test "utf16leToUtf8" {
{
mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 'A');
mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 'a');
- const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le);
+ const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le);
+ defer std.testing.allocator.free(utf8);
testing.expect(mem.eql(u8, utf8, "Aa"));
}
{
mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0x80);
mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xffff);
- const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le);
+ const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le);
+ defer std.testing.allocator.free(utf8);
testing.expect(mem.eql(u8, utf8, "\xc2\x80" ++ "\xef\xbf\xbf"));
}
@@ -516,7 +518,8 @@ test "utf16leToUtf8" {
// the values just outside the surrogate half range
mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xd7ff);
mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xe000);
- const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le);
+ const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le);
+ defer std.testing.allocator.free(utf8);
testing.expect(mem.eql(u8, utf8, "\xed\x9f\xbf" ++ "\xee\x80\x80"));
}
@@ -524,7 +527,8 @@ test "utf16leToUtf8" {
// smallest surrogate pair
mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xd800);
mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdc00);
- const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le);
+ const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le);
+ defer std.testing.allocator.free(utf8);
testing.expect(mem.eql(u8, utf8, "\xf0\x90\x80\x80"));
}
@@ -532,14 +536,16 @@ test "utf16leToUtf8" {
// largest surrogate pair
mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xdbff);
mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdfff);
- const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le);
+ const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le);
+ defer std.testing.allocator.free(utf8);
testing.expect(mem.eql(u8, utf8, "\xf4\x8f\xbf\xbf"));
}
{
mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xdbff);
mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdc00);
- const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le);
+ const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le);
+ defer std.testing.allocator.free(utf8);
testing.expect(mem.eql(u8, utf8, "\xf4\x8f\xb0\x80"));
}
}