diff options
| author | Qwerasd <qwerasd205@users.noreply.github.com> | 2025-05-01 18:37:24 -0600 |
|---|---|---|
| committer | Qwerasd <qwerasd205@users.noreply.github.com> | 2025-05-01 18:37:47 -0600 |
| commit | 5319d3836619ebbf2d7beefc17197f5c42fc1553 (patch) | |
| tree | da013bde1bbc9b90c0d1563942b6810cd3194fc9 /src | |
| parent | cfedd477b2843c4624aac88b76ec24cd7ecd36d6 (diff) | |
fix(tests): correctly deinit font faces
Diffstat (limited to 'src')
| -rw-r--r-- | src/font/Collection.zig | 21 | ||||
| -rw-r--r-- | src/font/DeferredFace.zig | 6 |
2 files changed, 16 insertions, 11 deletions
diff --git a/src/font/Collection.zig b/src/font/Collection.zig index 66e13c109..59f89d402 100644 --- a/src/font/Collection.zig +++ b/src/font/Collection.zig @@ -714,15 +714,18 @@ test "add full" { ) }); } - try testing.expectError(error.CollectionFull, c.add( - alloc, - .regular, - .{ .loaded = try Face.init( - lib, - testFont, - .{ .size = .{ .points = 12 } }, - ) }, - )); + var face = try Face.init( + lib, + testFont, + .{ .size = .{ .points = 12 } }, + ); + // We have to deinit it manually since the + // collection doesn't do it if adding fails. + defer face.deinit(); + try testing.expectError( + error.CollectionFull, + c.add(alloc, .regular, .{ .loaded = face }), + ); } test "add deferred without loading options" { diff --git a/src/font/DeferredFace.zig b/src/font/DeferredFace.zig index d61f5492f..8794ccea9 100644 --- a/src/font/DeferredFace.zig +++ b/src/font/DeferredFace.zig @@ -425,7 +425,8 @@ test "fontconfig" { try testing.expect(n.len > 0); // Load it and verify it works - const face = try def.load(lib, .{ .size = .{ .points = 12 } }); + var face = try def.load(lib, .{ .size = .{ .points = 12 } }); + defer face.deinit(); try testing.expect(face.glyphIndex(' ') != null); } @@ -456,6 +457,7 @@ test "coretext" { try testing.expect(n.len > 0); // Load it and verify it works - const face = try def.load(lib, .{ .size = .{ .points = 12 } }); + var face = try def.load(lib, .{ .size = .{ .points = 12 } }); + defer face.deinit(); try testing.expect(face.glyphIndex(' ') != null); } |
