open Year2024.Day01.Part01 let test_solve haveLeft haveRight want () = Alcotest.(check int) "incorrect solution" want @@ solve haveLeft haveRight let test_distance_calculation haveX haveY want () = Alcotest.(check int) "incorrect solution" want @@ calculate_distance haveX haveY let () = let open Alcotest in run "test suite for day 01 part 01" [ ( "test solutions" , [ test_case "empty list is 0" `Quick @@ (test_solve [] []) 0 ; test_case "distance between 0 and 1 is 1" `Quick @@ (test_solve [0] [1]) 1 ; test_case "distance between 1 and 0 is 1" `Quick @@ (test_solve [1] [0]) 1 ; test_case "smallest are paired, then next smallest, ..." `Quick @@ (test_solve [1; 2; 3] [3; 2; 1]) 0 ; test_case "solves example correctly" `Quick @@ (test_solve [3; 4; 2; 1; 3; 3] [4; 3; 5; 3; 9; 3]) 11 ; test_case "same number is 0 distance apart" `Quick @@ (test_distance_calculation 0 0) 0 ; test_case "same number is 0 distance apart" `Quick @@ (test_distance_calculation 1 1) 0 ; test_case "distance is equal to abs(x - y)" `Quick @@ (test_distance_calculation 0 1) 1 ; test_case "order of inputs doesn't matter" `Quick @@ (test_distance_calculation 1 0) 1 ] ) ]