Skip to content

Commit

Permalink
Merge pull request #2 from yamafaktory/fix/allocation-failure-test
Browse files Browse the repository at this point in the history
fix(tests): add allocation failure spec back
  • Loading branch information
yamafaktory authored Nov 30, 2024
2 parents 1252947 + 43d193d commit 47844aa
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/hypergraphz.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1108,17 +1108,17 @@ fn generateTestData(graph: *HypergraphZ(Hyperedge, Vertex)) !Data {
};
}

// test "allocation failure" {
// var failingAllocator = std.testing.FailingAllocator.init(std.testing.allocator, .{ .fail_index = 1 });
// var graph = try HypergraphZ(
// Hyperedge,
// Vertex,
// ).init(failingAllocator.allocator(), .{});
// defer graph.deinit();
//
// _ = try graph.createVertex(.{});
// try expectError(HypergraphZError.OutOfMemory, graph.createHyperedge(.{}));
// }
test "allocation failure" {
var failingAllocator = std.testing.FailingAllocator.init(std.testing.allocator, .{ .fail_index = 1 });
var graph = try HypergraphZ(
Hyperedge,
Vertex,
).init(failingAllocator.allocator(), .{});
defer graph.deinit();

// The following fails since two allocations are made.
try expectError(HypergraphZError.OutOfMemory, graph.createHyperedge(.{}));
}

test "create and get hyperedge" {
var graph = try scaffold();
Expand Down

0 comments on commit 47844aa

Please sign in to comment.