From 11b1678e0e4431a44a7674df3a83d20693d8aa9c Mon Sep 17 00:00:00 2001 From: Luuk Machielse Date: Sat, 11 Oct 2025 09:37:16 +0200 Subject: [PATCH] Moved `Zip` and `Empty` unit tests to `Iterator(T).zip` and `Iter(T).empty --- src/root.zig | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/root.zig b/src/root.zig index e994e9a..3102e6f 100644 --- a/src/root.zig +++ b/src/root.zig @@ -23,6 +23,14 @@ pub fn Iter(comptime T: type) type { pub fn empty() Iterator(Empty(T)) { return .{ .inner = .{} }; } + + test empty { + const testing = @import("std").testing; + + var it = Iter(i32).empty(); + + try testing.expectEqual(null, it.next()); + } }; } @@ -157,6 +165,14 @@ pub fn Iterator(comptime Inner: type) type { return .{ .inner = .{ .a = self.inner, .b = other.inner } }; } + test zip { + const testing = @import("std").testing; + + var it = Iter(i32).once(10).zip(Iter(i32).once(20)); + + try testing.expectEqualDeep(struct { i32, i32 }{ 10, 20 }, it.next().?); + } + pub fn toOwnedSlice(self: Self, gpa: std.mem.Allocator) ![]const Item { var list: std.ArrayList(Item) = .empty; errdefer list.deinit(gpa); @@ -300,14 +316,6 @@ pub const adapters = struct { } }; } - - test Zip { - const testing = @import("std").testing; - - var it = Iter(i32).once(10).zip(Iter(i32).once(20)); - - try testing.expectEqualDeep(struct { i32, i32 }{ 10, 20 }, it.next().?); - } }; pub fn Range(comptime T: type) type { @@ -402,11 +410,3 @@ pub fn Empty(comptime T: type) type { } }; } - -test Empty { - const testing = @import("std").testing; - - var it = Iter(i32).empty(); - - try testing.expectEqual(null, it.next()); -}