authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-11-02 11:48:06+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-11-02 11:48:06+01:00
log76e9a4ae8377a9329170b038ce7b393db0402862
tree2d1764b8b6e1d613f3582cb33dba748697156d8e
parent02efc2236a8223872f57a1a7a5aec756b5a23a76

std: Fix std.unicode test cases for BE targets


1 files changed, 20 insertions(+), 9 deletions(-)

lib/std/unicode.zig+20-9
......@@ -706,41 +706,52 @@ fn calcUtf16LeLen(utf8: []const u8) usize {
706706}
707707
708708test "utf8ToUtf16LeStringLiteral" {
709 // https://github.com/ziglang/zig/issues/5127
710 if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
711
712709 {
713 const bytes = [_:0]u16{0x41};
710 const bytes = [_:0]u16{
711 mem.nativeToLittle(u16, 0x41),
712 };
714713 const utf16 = utf8ToUtf16LeStringLiteral("A");
715714 testing.expectEqualSlices(u16, &bytes, utf16);
716715 testing.expect(utf16[1] == 0);
717716 }
718717 {
719 const bytes = [_:0]u16{ 0xD801, 0xDC37 };
718 const bytes = [_:0]u16{
719 mem.nativeToLittle(u16, 0xD801),
720 mem.nativeToLittle(u16, 0xDC37),
721 };
720722 const utf16 = utf8ToUtf16LeStringLiteral("𐐷");
721723 testing.expectEqualSlices(u16, &bytes, utf16);
722724 testing.expect(utf16[2] == 0);
723725 }
724726 {
725 const bytes = [_:0]u16{0x02FF};
727 const bytes = [_:0]u16{
728 mem.nativeToLittle(u16, 0x02FF),
729 };
726730 const utf16 = utf8ToUtf16LeStringLiteral("\u{02FF}");
727731 testing.expectEqualSlices(u16, &bytes, utf16);
728732 testing.expect(utf16[1] == 0);
729733 }
730734 {
731 const bytes = [_:0]u16{0x7FF};
735 const bytes = [_:0]u16{
736 mem.nativeToLittle(u16, 0x7FF),
737 };
732738 const utf16 = utf8ToUtf16LeStringLiteral("\u{7FF}");
733739 testing.expectEqualSlices(u16, &bytes, utf16);
734740 testing.expect(utf16[1] == 0);
735741 }
736742 {
737 const bytes = [_:0]u16{0x801};
743 const bytes = [_:0]u16{
744 mem.nativeToLittle(u16, 0x801),
745 };
738746 const utf16 = utf8ToUtf16LeStringLiteral("\u{801}");
739747 testing.expectEqualSlices(u16, &bytes, utf16);
740748 testing.expect(utf16[1] == 0);
741749 }
742750 {
743 const bytes = [_:0]u16{ 0xDBFF, 0xDFFF };
751 const bytes = [_:0]u16{
752 mem.nativeToLittle(u16, 0xDBFF),
753 mem.nativeToLittle(u16, 0xDFFF),
754 };
744755 const utf16 = utf8ToUtf16LeStringLiteral("\u{10FFFF}");
745756 testing.expectEqualSlices(u16, &bytes, utf16);
746757 testing.expect(utf16[2] == 0);