diff options
| author | 2025-04-29 15:32:58 -0400 | |
|---|---|---|
| committer | 2025-04-29 15:32:58 -0400 | |
| commit | 35f18e584fae890f686eafcdc12a2fde6281206d (patch) | |
| tree | 4006551bfb221e80fb6c9173383ce48f308c4512 /src/Normalize.zig | |
| parent | Add result.toOwned() to Normalize.zig (diff) | |
| download | zg-35f18e584fae890f686eafcdc12a2fde6281206d.tar.gz zg-35f18e584fae890f686eafcdc12a2fde6281206d.tar.xz zg-35f18e584fae890f686eafcdc12a2fde6281206d.zip | |
Add general tests step
After a considerable slog, all tests are reachable from the test step,
and pass. Almost every failure was related to the change away from the
inclusion of an allocator on this or that.
Diffstat (limited to 'src/Normalize.zig')
| -rw-r--r-- | src/Normalize.zig | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/Normalize.zig b/src/Normalize.zig index 97c2649..a28b708 100644 --- a/src/Normalize.zig +++ b/src/Normalize.zig | |||
| @@ -229,7 +229,7 @@ pub const Result = struct { | |||
| 229 | 229 | ||
| 230 | /// Ensures that the slice result is a copy of the input, by making a copy if it was not. | 230 | /// Ensures that the slice result is a copy of the input, by making a copy if it was not. |
| 231 | pub fn toOwned(result: Result, allocator: mem.Allocator) error{OutOfMemory}!Result { | 231 | pub fn toOwned(result: Result, allocator: mem.Allocator) error{OutOfMemory}!Result { |
| 232 | if (result.allocatod) return result; | 232 | if (result.allocated) return result; |
| 233 | return .{ .allocated = true, .slice = try allocator.dupe(u8, result.slice) }; | 233 | return .{ .allocated = true, .slice = try allocator.dupe(u8, result.slice) }; |
| 234 | } | 234 | } |
| 235 | 235 | ||
| @@ -571,9 +571,9 @@ test "nfkc" { | |||
| 571 | /// Tests for equality of `a` and `b` after normalizing to NFC. | 571 | /// Tests for equality of `a` and `b` after normalizing to NFC. |
| 572 | pub fn eql(self: Self, allocator: mem.Allocator, a: []const u8, b: []const u8) !bool { | 572 | pub fn eql(self: Self, allocator: mem.Allocator, a: []const u8, b: []const u8) !bool { |
| 573 | const norm_result_a = try self.nfc(allocator, a); | 573 | const norm_result_a = try self.nfc(allocator, a); |
| 574 | defer norm_result_a.deinit(); | 574 | defer norm_result_a.deinit(allocator); |
| 575 | const norm_result_b = try self.nfc(allocator, b); | 575 | const norm_result_b = try self.nfc(allocator, b); |
| 576 | defer norm_result_b.deinit(); | 576 | defer norm_result_b.deinit(allocator); |
| 577 | 577 | ||
| 578 | return mem.eql(u8, norm_result_a.slice, norm_result_b.slice); | 578 | return mem.eql(u8, norm_result_a.slice, norm_result_b.slice); |
| 579 | } | 579 | } |
| @@ -628,4 +628,5 @@ test "isLatin1Only" { | |||
| 628 | try testing.expect(isLatin1Only(latin1_only)); | 628 | try testing.expect(isLatin1Only(latin1_only)); |
| 629 | const not_latin1_only = "Héllo, World! \u{3d3}"; | 629 | const not_latin1_only = "Héllo, World! \u{3d3}"; |
| 630 | try testing.expect(!isLatin1Only(not_latin1_only)); | 630 | try testing.expect(!isLatin1Only(not_latin1_only)); |
| 631 | try testing.expect(false); | ||
| 631 | } | 632 | } |