refactor testcases

This commit is contained in:
Rokas Puzonas 2023-12-17 13:14:01 +02:00
parent a15d429279
commit c5bf80a9b5
7 changed files with 15 additions and 50 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
zig-cache
zig-out
input.txt

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}