Skip to content

Commit

Permalink
add tests for day12 (#3)
Browse files Browse the repository at this point in the history
* add tests for day12

* set C standard to C99 when compile for test

* remove day12 test

* run on ubuntu

* add day12 back in

* add newline

* simplify day17 tests

* add -e

* add -e another place

* simplify test case to check if it is a memory issue

* make testcase a bit better

* revert changes to day12/main.c
  • Loading branch information
Thomas-mcinally authored Jan 29, 2024
1 parent d62eff2 commit 08af5c7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
6 changes: 1 addition & 5 deletions day12/tests/test_input.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
???.### 1,1,3
.??..??...?##. 1,1,3
?#?#?#?#?#?#?#? 1,3,1,6
????.#...#... 4,1,1
????.######..#####. 1,6,5
?###???????? 3,2,1
.??..??...?##. 1,1,3
9 changes: 9 additions & 0 deletions day12/tests/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e
cd "$(dirname "$0")"

source ../../test_utils/run_test.sh

echo "Running tests for day12"
run_test "part1" "./test_input.txt" "../main.c" "Part1 sol: 5"
run_test "part2" "./test_input.txt" "../main.c" "Part2 sol: 16385"
1 change: 1 addition & 0 deletions day13/tests/tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e
cd "$(dirname "$0")"

source ../../test_utils/run_test.sh
Expand Down
10 changes: 3 additions & 7 deletions day17/tests/tests.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#!/bin/bash
set -e
cd "$(dirname "$0")"

source ../../test_utils/run_test.sh

echo "Running tests for day17"
if ! run_test "part1" "./test_input.txt" "../main.c" "Part1 sol: 102"; then
exit 1
fi
if ! run_test "part2" "./test_input.txt" "../main.c" "Part2 sol: 94"; then
exit 1
fi

run_test "part1" "./test_input.txt" "../main.c" "Part1 sol: 102"
run_test "part2" "./test_input.txt" "../main.c" "Part2 sol: 94"
2 changes: 1 addition & 1 deletion test_utils/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ run_test() {
main_file_relative_path=$3
expected_output=$4

eval "clang $main_file_relative_path ../../libs/aoc_lib.c -I ../../libs -lm"
eval "clang $main_file_relative_path ../../libs/aoc_lib.c -I ../../libs -lm -std=c99"
output=$(./a.out $input_file_relative_path)
rm ./a.out

Expand Down

0 comments on commit 08af5c7

Please sign in to comment.