Skip to content

Commit

Permalink
Use testing allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
bondehagen committed Jan 8, 2025
1 parent 70542a0 commit 7a1dc03
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/std/net/test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test "format IPv6 address with no zero runs" {
test "parse IPv6 addresses and check compressed form" {
if (builtin.os.tag == .wasi) return error.SkipZigTest;

const alloc = std.heap.page_allocator;
const alloc = testing.allocator;

// 1) Parse an IPv6 address that should compress to [2001:db8::1:0:0:2]:0
const addr1 = try std.net.Address.parseIp6("2001:0db8:0000:0000:0001:0000:0000:0002", 0);
Expand All @@ -53,8 +53,11 @@ test "parse IPv6 addresses and check compressed form" {

// Print each address in Zig's default "[ipv6]:port" form.
const printed1 = try std.fmt.allocPrint(alloc, "{any}", .{addr1});
defer testing.allocator.free(printed1);
const printed2 = try std.fmt.allocPrint(alloc, "{any}", .{addr2});
defer testing.allocator.free(printed2);
const printed3 = try std.fmt.allocPrint(alloc, "{any}", .{addr3});
defer testing.allocator.free(printed3);

// Check the exact compressed forms we expect.
try std.testing.expectEqualStrings("[2001:db8::1:0:0:2]:0", printed1);
Expand Down

0 comments on commit 7a1dc03

Please sign in to comment.