refactor testcases
This commit is contained in:
parent
a15d429279
commit
c5bf80a9b5
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
zig-cache
|
||||
zig-out
|
||||
input.txt
|
||||
|
14
src/day1.zig
14
src/day1.zig
@ -94,20 +94,17 @@ pub fn part2(input: *aoc.Input) !aoc.Result {
|
||||
}
|
||||
|
||||
test "part 1 example" {
|
||||
var lines = [_][]const u8{
|
||||
var example_input = [_][]const u8{
|
||||
"1abc2",
|
||||
"pqr3stu8vwx",
|
||||
"a1b2c3d4e5f",
|
||||
"treb7uchet",
|
||||
};
|
||||
var input = aoc.Input{ .lines = &lines, .allocator = std.testing.allocator };
|
||||
var actual = try part1(&input);
|
||||
var expected: u32 = 142;
|
||||
try std.testing.expectEqual(expected, actual.uint);
|
||||
try aoc.expectAnswerUInt(part1, 142, &example_input);
|
||||
}
|
||||
|
||||
test "part 2 example" {
|
||||
var lines = [_][]const u8{
|
||||
var example_input = [_][]const u8{
|
||||
"two1nine",
|
||||
"eightwothree",
|
||||
"abcone2threexyz",
|
||||
@ -116,8 +113,5 @@ test "part 2 example" {
|
||||
"zoneight234",
|
||||
"7pqrstsixteen",
|
||||
};
|
||||
var input = aoc.Input{ .lines = &lines, .allocator = std.testing.allocator };
|
||||
var actual = try part2(&input);
|
||||
var expected: u32 = 281;
|
||||
try std.testing.expectEqual(expected, actual.uint);
|
||||
try aoc.expectAnswerUInt(part2, 281, &example_input);
|
||||
}
|
||||
|
10
src/day2.zig
10
src/day2.zig
@ -111,15 +111,9 @@ const example_input = [_][]const u8{
|
||||
};
|
||||
|
||||
test "part 1 example" {
|
||||
var input = aoc.Input{ .lines = &example_input, .allocator = std.testing.allocator };
|
||||
var actual = try part1(&input);
|
||||
var expected: u32 = 8;
|
||||
try std.testing.expectEqual(expected, actual.uint);
|
||||
try aoc.expectAnswerUInt(part1, 8, &example_input);
|
||||
}
|
||||
|
||||
test "part 2 example" {
|
||||
var input = aoc.Input{ .lines = &example_input, .allocator = std.testing.allocator };
|
||||
var actual = try part2(&input);
|
||||
var expected: u32 = 2286;
|
||||
try std.testing.expectEqual(expected, actual.uint);
|
||||
try aoc.expectAnswerUInt(part2, 2286, &example_input);
|
||||
}
|
||||
|
10
src/day3.zig
10
src/day3.zig
@ -121,15 +121,9 @@ const example_input = [_][]const u8{
|
||||
};
|
||||
|
||||
test "part 1 example" {
|
||||
var input = aoc.Input{ .lines = &example_input, .allocator = std.testing.allocator };
|
||||
var actual = try part1(&input);
|
||||
var expected: u32 = 4361;
|
||||
try std.testing.expectEqual(expected, actual.uint);
|
||||
try aoc.expectAnswerUInt(part1, 4361, &example_input);
|
||||
}
|
||||
|
||||
test "part 2 example" {
|
||||
var input = aoc.Input{ .lines = &example_input, .allocator = std.testing.allocator };
|
||||
var actual = try part2(&input);
|
||||
var expected: u32 = 467835;
|
||||
try std.testing.expectEqual(expected, actual.uint);
|
||||
try aoc.expectAnswerUInt(part2, 467835, &example_input);
|
||||
}
|
||||
|
10
src/day4.zig
10
src/day4.zig
@ -105,15 +105,9 @@ const example_input = [_][]const u8{
|
||||
};
|
||||
|
||||
test "part 1 example" {
|
||||
var input = aoc.Input{ .lines = &example_input, .allocator = std.testing.allocator };
|
||||
var actual = try part1(&input);
|
||||
var expected: u32 = 13;
|
||||
try std.testing.expectEqual(expected, actual.uint);
|
||||
try aoc.expectAnswerUInt(part1, 13, &example_input);
|
||||
}
|
||||
|
||||
test "part 2 example" {
|
||||
var input = aoc.Input{ .lines = &example_input, .allocator = std.testing.allocator };
|
||||
var actual = try part2(&input);
|
||||
var expected: u32 = 30;
|
||||
try std.testing.expectEqual(expected, actual.uint);
|
||||
try aoc.expectAnswerUInt(part2, 30, &example_input);
|
||||
}
|
||||
|
10
src/day5.zig
10
src/day5.zig
@ -249,16 +249,10 @@ const example_input = [_][]const u8{
|
||||
};
|
||||
|
||||
test "part 1 example" {
|
||||
var input = aoc.Input{ .lines = &example_input, .allocator = std.testing.allocator };
|
||||
var actual = try part1(&input);
|
||||
var expected: u32 = 35;
|
||||
try std.testing.expectEqual(expected, actual.uint);
|
||||
try aoc.expectAnswerUInt(part1, 35, &example_input);
|
||||
}
|
||||
|
||||
test "part 2 example" {
|
||||
var input = aoc.Input{ .lines = &example_input, .allocator = std.testing.allocator };
|
||||
var actual = try part2(&input);
|
||||
var expected: u32 = 46;
|
||||
try std.testing.expectEqual(expected, actual.uint);
|
||||
try aoc.expectAnswerUInt(part2, 46, &example_input);
|
||||
}
|
||||
|
||||
|
10
src/day6.zig
10
src/day6.zig
@ -101,15 +101,9 @@ const example_input = [_][]const u8{
|
||||
};
|
||||
|
||||
test "part 1 example" {
|
||||
var input = aoc.Input{ .lines = &example_input, .allocator = std.testing.allocator };
|
||||
var actual = try part1(&input);
|
||||
var expected: u32 = 288;
|
||||
try std.testing.expectEqual(expected, actual.uint);
|
||||
try aoc.expectAnswerUInt(part1, 288, &example_input);
|
||||
}
|
||||
|
||||
test "part 2 example" {
|
||||
var input = aoc.Input{ .lines = &example_input, .allocator = std.testing.allocator };
|
||||
var actual = try part2(&input);
|
||||
var expected: u32 = 71503;
|
||||
try std.testing.expectEqual(expected, actual.uint);
|
||||
try aoc.expectAnswerUInt(part2, 71503, &example_input);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user