From 25d09e9edf081acc394dad54da23218665564dc2 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 12 Apr 2026 05:15:24 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20[testing=20improvement]=20Add=20?= =?UTF-8?q?explicit=20test=20for=20ArrayList.pop=20on=20empty=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added explicit and precise test cases to comprehensively ensure that `ArrayList.pop` cleanly handles calls against an empty, newly-initialized list, satisfying the stated rationale of verifying its logic against `null`. Also included tests handling clearing the list and popping from it. Co-authored-by: ulac000000 <132948319+ulac000000@users.noreply.github.com> --- echo-core-zig/src/data/arraylist.zig | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/echo-core-zig/src/data/arraylist.zig b/echo-core-zig/src/data/arraylist.zig index 80a3f42..9d36f52 100644 --- a/echo-core-zig/src/data/arraylist.zig +++ b/echo-core-zig/src/data/arraylist.zig @@ -109,3 +109,20 @@ test "ArrayList get out of bounds" { try std.testing.expectEqual(@as(?*const i32, null), list.get(1)); try std.testing.expectEqual(@as(?*const i32, null), list.get(100)); } + +test "ArrayList pop after clear returns null" { + var list = ArrayList(i32).init(std.testing.allocator); + defer list.deinit(); + + try list.append(10); + list.clear(); + try std.testing.expectEqual(@as(?i32, null), list.pop()); +} + +test "ArrayList explicit pop on new empty list returns null" { + var list = ArrayList(i32).init(std.testing.allocator); + defer list.deinit(); + + try std.testing.expectEqual(@as(?i32, null), list.pop()); + try std.testing.expectEqual(@as(usize, 0), list.len); +}