std.json: delete test tightly coupled to ArrayList growth

This test works by assuming that std.ArrayList will grow with a specific
capacity increasing pattern, which is an invalid assumption. Delete the
offending test.
This commit is contained in:
Andrew Kelley 2025-09-20 14:38:01 -07:00
parent 0c1fbc4ea6
commit 3cc0fc601a
2 changed files with 1 additions and 28 deletions

View file

@ -431,33 +431,6 @@ test "skipValue" {
try std.testing.expectError(error.SyntaxError, testSkipValue("[102, 111, 111}"));
}
fn testEnsureStackCapacity(do_ensure: bool) !void {
var fail_alloc = std.testing.FailingAllocator.init(std.testing.allocator, .{ .fail_index = 1 });
const failing_allocator = fail_alloc.allocator();
const nestings = 2049; // intentionally not a power of 2.
var input_string: std.ArrayListUnmanaged(u8) = .empty;
try input_string.appendNTimes(std.testing.allocator, '[', nestings);
try input_string.appendNTimes(std.testing.allocator, ']', nestings);
defer input_string.deinit(std.testing.allocator);
var scanner = Scanner.initCompleteInput(failing_allocator, input_string.items);
defer scanner.deinit();
if (do_ensure) {
try scanner.ensureTotalStackCapacity(nestings);
}
try scanner.skipValue();
try std.testing.expectEqual(Token.end_of_document, try scanner.next());
}
test "ensureTotalStackCapacity" {
// Once to demonstrate failure.
try std.testing.expectError(error.OutOfMemory, testEnsureStackCapacity(false));
// Then to demonstrate it works.
try testEnsureStackCapacity(true);
}
fn testDiagnosticsFromSource(expected_error: ?anyerror, line: u64, col: u64, byte_offset: u64, source: anytype) !void {
var diagnostics = Diagnostics{};
source.enableDiagnostics(&diagnostics);

View file

@ -914,7 +914,7 @@ test "parse at comptime" {
uptime: u64,
};
const config = comptime x: {
var buf: [256]u8 = undefined;
var buf: [300]u8 = undefined;
var fba = std.heap.FixedBufferAllocator.init(&buf);
const res = parseFromSliceLeaky(Config, fba.allocator(), doc, .{});
// Assert no error can occur since we are