aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2020-11-02 11:48:06 +0100
committerLemonBoy <thatlemon@gmail.com>2020-11-02 11:48:06 +0100
commit76e9a4ae8377a9329170b038ce7b393db0402862 (patch)
tree2d1764b8b6e1d613f3582cb33dba748697156d8e /lib/std
parent02efc2236a8223872f57a1a7a5aec756b5a23a76 (diff)
downloadzig-76e9a4ae8377a9329170b038ce7b393db0402862.tar.gz
zig-76e9a4ae8377a9329170b038ce7b393db0402862.zip
std: Fix std.unicode test cases for BE targets
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/unicode.zig29
1 files changed, 20 insertions, 9 deletions
diff --git a/lib/std/unicode.zig b/lib/std/unicode.zig
index 86b805b892..18bd5ab0e2 100644
--- a/lib/std/unicode.zig
+++ b/lib/std/unicode.zig
@@ -706,41 +706,52 @@ fn calcUtf16LeLen(utf8: []const u8) usize {
}
test "utf8ToUtf16LeStringLiteral" {
- // https://github.com/ziglang/zig/issues/5127
- if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
-
{
- const bytes = [_:0]u16{0x41};
+ const bytes = [_:0]u16{
+ mem.nativeToLittle(u16, 0x41),
+ };
const utf16 = utf8ToUtf16LeStringLiteral("A");
testing.expectEqualSlices(u16, &bytes, utf16);
testing.expect(utf16[1] == 0);
}
{
- const bytes = [_:0]u16{ 0xD801, 0xDC37 };
+ const bytes = [_:0]u16{
+ mem.nativeToLittle(u16, 0xD801),
+ mem.nativeToLittle(u16, 0xDC37),
+ };
const utf16 = utf8ToUtf16LeStringLiteral("𐐷");
testing.expectEqualSlices(u16, &bytes, utf16);
testing.expect(utf16[2] == 0);
}
{
- const bytes = [_:0]u16{0x02FF};
+ const bytes = [_:0]u16{
+ mem.nativeToLittle(u16, 0x02FF),
+ };
const utf16 = utf8ToUtf16LeStringLiteral("\u{02FF}");
testing.expectEqualSlices(u16, &bytes, utf16);
testing.expect(utf16[1] == 0);
}
{
- const bytes = [_:0]u16{0x7FF};
+ const bytes = [_:0]u16{
+ mem.nativeToLittle(u16, 0x7FF),
+ };
const utf16 = utf8ToUtf16LeStringLiteral("\u{7FF}");
testing.expectEqualSlices(u16, &bytes, utf16);
testing.expect(utf16[1] == 0);
}
{
- const bytes = [_:0]u16{0x801};
+ const bytes = [_:0]u16{
+ mem.nativeToLittle(u16, 0x801),
+ };
const utf16 = utf8ToUtf16LeStringLiteral("\u{801}");
testing.expectEqualSlices(u16, &bytes, utf16);
testing.expect(utf16[1] == 0);
}
{
- const bytes = [_:0]u16{ 0xDBFF, 0xDFFF };
+ const bytes = [_:0]u16{
+ mem.nativeToLittle(u16, 0xDBFF),
+ mem.nativeToLittle(u16, 0xDFFF),
+ };
const utf16 = utf8ToUtf16LeStringLiteral("\u{10FFFF}");
testing.expectEqualSlices(u16, &bytes, utf16);
testing.expect(utf16[2] == 0);