diff options
Diffstat (limited to 'src/WidthData.zig')
| -rw-r--r-- | src/WidthData.zig | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/src/WidthData.zig b/src/WidthData.zig index 4a49c80..b07a679 100644 --- a/src/WidthData.zig +++ b/src/WidthData.zig | |||
| @@ -55,28 +55,30 @@ pub fn codePointWidth(self: Self, cp: u21) i4 { | |||
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | test "codePointWidth" { | 57 | test "codePointWidth" { |
| 58 | try testing.expectEqual(@as(i4, 0), codePointWidth(0x0000)); // null | 58 | const wd = try Self.init(std.testing.allocator); |
| 59 | try testing.expectEqual(@as(i4, -1), codePointWidth(0x8)); // \b | 59 | defer wd.deinit(std.testing.allocator); |
| 60 | try testing.expectEqual(@as(i4, -1), codePointWidth(0x7f)); // DEL | 60 | try testing.expectEqual(@as(i4, 0), wd.codePointWidth(0x0000)); // null |
| 61 | try testing.expectEqual(@as(i4, 0), codePointWidth(0x0005)); // Cf | 61 | try testing.expectEqual(@as(i4, -1), wd.codePointWidth(0x8)); // \b |
| 62 | try testing.expectEqual(@as(i4, 0), codePointWidth(0x0007)); // \a BEL | 62 | try testing.expectEqual(@as(i4, -1), wd.codePointWidth(0x7f)); // DEL |
| 63 | try testing.expectEqual(@as(i4, 0), codePointWidth(0x000A)); // \n LF | 63 | try testing.expectEqual(@as(i4, 0), wd.codePointWidth(0x0005)); // Cf |
| 64 | try testing.expectEqual(@as(i4, 0), codePointWidth(0x000B)); // \v VT | 64 | try testing.expectEqual(@as(i4, 0), wd.codePointWidth(0x0007)); // \a BEL |
| 65 | try testing.expectEqual(@as(i4, 0), codePointWidth(0x000C)); // \f FF | 65 | try testing.expectEqual(@as(i4, 0), wd.codePointWidth(0x000A)); // \n LF |
| 66 | try testing.expectEqual(@as(i4, 0), codePointWidth(0x000D)); // \r CR | 66 | try testing.expectEqual(@as(i4, 0), wd.codePointWidth(0x000B)); // \v VT |
| 67 | try testing.expectEqual(@as(i4, 0), codePointWidth(0x000E)); // SQ | 67 | try testing.expectEqual(@as(i4, 0), wd.codePointWidth(0x000C)); // \f FF |
| 68 | try testing.expectEqual(@as(i4, 0), codePointWidth(0x000F)); // SI | 68 | try testing.expectEqual(@as(i4, 0), wd.codePointWidth(0x000D)); // \r CR |
| 69 | 69 | try testing.expectEqual(@as(i4, 0), wd.codePointWidth(0x000E)); // SQ | |
| 70 | try testing.expectEqual(@as(i4, 0), codePointWidth(0x070F)); // Cf | 70 | try testing.expectEqual(@as(i4, 0), wd.codePointWidth(0x000F)); // SI |
| 71 | try testing.expectEqual(@as(i4, 1), codePointWidth(0x0603)); // Cf Arabic | 71 | |
| 72 | 72 | try testing.expectEqual(@as(i4, 0), wd.codePointWidth(0x070F)); // Cf | |
| 73 | try testing.expectEqual(@as(i4, 1), codePointWidth(0x00AD)); // soft-hyphen | 73 | try testing.expectEqual(@as(i4, 1), wd.codePointWidth(0x0603)); // Cf Arabic |
| 74 | try testing.expectEqual(@as(i4, 2), codePointWidth(0x2E3A)); // two-em dash | 74 | |
| 75 | try testing.expectEqual(@as(i4, 3), codePointWidth(0x2E3B)); // three-em dash | 75 | try testing.expectEqual(@as(i4, 1), wd.codePointWidth(0x00AD)); // soft-hyphen |
| 76 | 76 | try testing.expectEqual(@as(i4, 2), wd.codePointWidth(0x2E3A)); // two-em dash | |
| 77 | try testing.expectEqual(@as(i4, 1), codePointWidth(0x00BD)); // ambiguous halfwidth | 77 | try testing.expectEqual(@as(i4, 3), wd.codePointWidth(0x2E3B)); // three-em dash |
| 78 | 78 | ||
| 79 | try testing.expectEqual(@as(i4, 1), codePointWidth('é')); | 79 | try testing.expectEqual(@as(i4, 1), wd.codePointWidth(0x00BD)); // ambiguous halfwidth |
| 80 | try testing.expectEqual(@as(i4, 2), codePointWidth('😊')); | 80 | |
| 81 | try testing.expectEqual(@as(i4, 2), codePointWidth('统')); | 81 | try testing.expectEqual(@as(i4, 1), wd.codePointWidth('é')); |
| 82 | try testing.expectEqual(@as(i4, 2), wd.codePointWidth('😊')); | ||
| 83 | try testing.expectEqual(@as(i4, 2), wd.codePointWidth('统')); | ||
| 82 | } | 84 | } |