diff --git a/generate.ts b/generate.ts index 69c032c5ca6e5f9b6882f04009dc4195c8af7d87..9e1172d1fae3544e47fddee21dcbb7ebc6f6344c 100644 --- a/generate.ts +++ b/generate.ts @@ -61,10 +61,11 @@ const E = stringEscape; w.write(` pub fn parseFail(input: []const u8, base: ?[]const u8) !void { const allocator = std.testing.allocator; - _ = url.URL.parse(allocator, input, base) catch |err| switch (err) { + const u = url.URL.parse(allocator, input, base) catch |err| switch (err) { error.InvalidURL => return, error.OutOfMemory => return error.OutOfMemory, }; + defer allocator.free(u.href); return error.FailZigTest; } @@ -87,10 +88,11 @@ pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin: pub fn parseIDNAFail(comptime input: []const u8) !void { const allocator = std.testing.allocator; - _ = url.URL.parse(allocator, "https://" ++ input ++ "/x", null) catch |err| switch (err) { + const u = url.URL.parse(allocator, "https://" ++ input ++ "/x", null) catch |err| switch (err) { error.InvalidURL => return, error.OutOfMemory => return error.OutOfMemory, }; + defer allocator.free(u.href); return error.FailZigTest; } diff --git a/zig-out/test.zig b/zig-out/test.zig index e85facde221c8342a8b4eb65ef865e1f4092e64f..ab9c75de824e363b1f9b73c7f2076ba1c84816ed 100644 --- a/zig-out/test.zig +++ b/zig-out/test.zig @@ -6,10 +6,11 @@ const expect = @import("expect").expect; pub fn parseFail(input: []const u8, base: ?[]const u8) !void { const allocator = std.testing.allocator; - _ = url.URL.parse(allocator, input, base) catch |err| switch (err) { + const u = url.URL.parse(allocator, input, base) catch |err| switch (err) { error.InvalidURL => return, error.OutOfMemory => return error.OutOfMemory, }; + defer allocator.free(u.href); return error.FailZigTest; } @@ -32,10 +33,11 @@ pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin: pub fn parseIDNAFail(comptime input: []const u8) !void { const allocator = std.testing.allocator; - _ = url.URL.parse(allocator, "https://" ++ input ++ "/x", null) catch |err| switch (err) { + const u = url.URL.parse(allocator, "https://" ++ input ++ "/x", null) catch |err| switch (err) { error.InvalidURL => return, error.OutOfMemory => return error.OutOfMemory, }; + defer allocator.free(u.href); return error.FailZigTest; }