Add test cases for whitespace handling for ColorList

This commit is contained in:
Bryan Lee
2025-02-22 22:11:35 +08:00
parent 7c6375f744
commit 1b6b029e0d

View File

@ -4409,6 +4409,14 @@ pub const ColorList = struct {
try p.parseCLI(alloc, "black,white"); try p.parseCLI(alloc, "black,white");
try testing.expectEqual(2, p.colors.items.len); try testing.expectEqual(2, p.colors.items.len);
// Test whitespace handling
try p.parseCLI(alloc, "black, white"); // space after comma
try testing.expectEqual(2, p.colors.items.len);
try p.parseCLI(alloc, "black , white"); // spaces around comma
try testing.expectEqual(2, p.colors.items.len);
try p.parseCLI(alloc, " black , white "); // extra spaces at ends
try testing.expectEqual(2, p.colors.items.len);
// Error cases // Error cases
try testing.expectError(error.ValueRequired, p.parseCLI(alloc, null)); try testing.expectError(error.ValueRequired, p.parseCLI(alloc, null));
try testing.expectError(error.InvalidValue, p.parseCLI(alloc, " ")); try testing.expectError(error.InvalidValue, p.parseCLI(alloc, " "));