summaryrefslogtreecommitdiff
path: root/src/Scripts.zig
diff options
context:
space:
mode:
authorGravatar Sam Atman2025-04-30 20:30:39 -0400
committerGravatar Sam Atman2025-04-30 20:30:39 -0400
commit10048b0d31d0db923ae39c6bbd67139ed6252f6f (patch)
tree65df1666aacd102f59b4ac0844ccc7f7ddda91db /src/Scripts.zig
parentSetup variants for all allocating modules (diff)
downloadzg-10048b0d31d0db923ae39c6bbd67139ed6252f6f.tar.gz
zg-10048b0d31d0db923ae39c6bbd67139ed6252f6f.tar.xz
zg-10048b0d31d0db923ae39c6bbd67139ed6252f6f.zip
Allocation Failure Tests
These turned up an excessive amount of allocations in CanonData and CompatData, which have been reduced to two through the somewhat squirrely use of 'magic numbers'. There are now allocation tests for every allocated structure in the library, and they run to completion in a reasonable amount of time. So, that's nice.
Diffstat (limited to 'src/Scripts.zig')
-rw-r--r--src/Scripts.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Scripts.zig b/src/Scripts.zig
index f71a2b5..fd5fde9 100644
--- a/src/Scripts.zig
+++ b/src/Scripts.zig
@@ -233,6 +233,15 @@ test "script" {
233 try testing.expectEqual(Script.Latin, self.script('A').?); 233 try testing.expectEqual(Script.Latin, self.script('A').?);
234} 234}
235 235
236fn testAllocator(allocator: Allocator) !void {
237 var prop = try Scripts.init(allocator);
238 prop.deinit(allocator);
239}
240
241test "Allocation failure" {
242 try testing.checkAllAllocationFailures(testing.allocator, testAllocator, .{});
243}
244
236const std = @import("std"); 245const std = @import("std");
237const builtin = @import("builtin"); 246const builtin = @import("builtin");
238const compress = std.compress; 247const compress = std.compress;