From 10048b0d31d0db923ae39c6bbd67139ed6252f6f Mon Sep 17 00:00:00 2001 From: Sam Atman Date: Wed, 30 Apr 2025 20:30:39 -0400 Subject: 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. --- src/Scripts.zig | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Scripts.zig') 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" { try testing.expectEqual(Script.Latin, self.script('A').?); } +fn testAllocator(allocator: Allocator) !void { + var prop = try Scripts.init(allocator); + prop.deinit(allocator); +} + +test "Allocation failure" { + try testing.checkAllAllocationFailures(testing.allocator, testAllocator, .{}); +} + const std = @import("std"); const builtin = @import("builtin"); const compress = std.compress; -- cgit v1.2.3