diff options
| author | DJ O'Leary <dijitol@proton.me> | 2025-11-29 20:23:02 +0100 |
|---|---|---|
| committer | DJ O'Leary <dijitol@proton.me> | 2025-11-29 20:23:02 +0100 |
| commit | 4c3a50166bf0f78ce89459c352cc1c6536a8b96d (patch) | |
| tree | 02e4b66a1435680ef1e92bf82576747b27f16447 /2024/ocaml/test/day_01_part_01.ml | |
| parent | be2f8528b3829f8263507da301812d852297c168 (diff) | |
chore: make language folders snake_case
Diffstat (limited to '2024/ocaml/test/day_01_part_01.ml')
| -rw-r--r-- | 2024/ocaml/test/day_01_part_01.ml | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/2024/ocaml/test/day_01_part_01.ml b/2024/ocaml/test/day_01_part_01.ml new file mode 100644 index 0000000..824c95b --- /dev/null +++ b/2024/ocaml/test/day_01_part_01.ml @@ -0,0 +1,27 @@ +open OUnit2 +open AoC_2024.Day_01.Part_01 + +let tests = + "test suite for day 01 part 01" + >::: [ + ("empty list is 0" >:: fun _ -> assert_equal 0 (solve [] [])); + ( "distance between 0 and 1 is 1" >:: fun _ -> + assert_equal 1 (solve [ 0 ] [ 1 ]) ); + ( "distance between 1 and 0 is 1" >:: fun _ -> + assert_equal 1 (solve [ 1 ] [ 0 ]) ); + ( "smallest are paired, then next smallest, ..." >:: fun _ -> + assert_equal 0 (solve [ 1; 2; 3 ] [ 3; 2; 1 ]) ); + (* See https://adventofcode.com/2024/day/1 *) + ( "solves example correctly" >:: fun _ -> + assert_equal 11 (solve [ 3; 4; 2; 1; 3; 3 ] [ 4; 3; 5; 3; 9; 3 ]) ); + ( "same number is 0 distance apart" >:: fun _ -> + assert_equal 0 (calculate_distance 0 0) ); + ( "same number is 0 distance apart" >:: fun _ -> + assert_equal 0 (calculate_distance 1 1) ); + ( "distance is equal to abs(x - y)" >:: fun _ -> + assert_equal 1 (calculate_distance 0 1) ); + ( "order of inputs doesn't matter" >:: fun _ -> + assert_equal 1 (calculate_distance 1 0) ); + ] + +let _ = run_test_tt_main tests |
