-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c8b024
commit 81a7760
Showing
7 changed files
with
445 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ | |
"build.zig", | ||
"build.zig.zon", | ||
"src", | ||
"tests", | ||
// For example... | ||
"LICENSE", | ||
"README.md", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const std = @import("std"); | ||
const parseInt = std.fmt.parseInt; | ||
|
||
test "parse integers" { | ||
const input = "123 67 89,99"; | ||
const ally = std.testing.allocator; | ||
|
||
var list = std.ArrayList(u32).init(ally); | ||
// Ensure the list is freed at scope exit. | ||
// Try commenting out this line! | ||
defer list.deinit(); | ||
|
||
var it = std.mem.tokenizeAny(u8, input, " ,"); | ||
while (it.next()) |num| { | ||
const n = try parseInt(u32, num, 10); | ||
try list.append(n); | ||
} | ||
|
||
const expected = [_]u32{ 123, 67, 89, 99 }; | ||
|
||
for (expected, list.items) |exp, actual| { | ||
try std.testing.expectEqual(exp, actual); | ||
} | ||
} |
Oops, something went wrong.