open Year2024.Day03.Part01 let example_input = "xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5))" let test_find_mul () = Alcotest.(check (list string)) "incorrect mul list found" ["mul(2,4)"; "mul(5,5)"; "mul(11,8)"; "mul(8,5)"] (let result = find_mul example_input in List.map (fun x -> Re2.Match.get_exn x ~sub:(`Index 0)) result ) let test_extract_pairs () = Alcotest.(check (list (pair int int))) "incorrect pairs" [(2, 4); (5, 5); (11, 8); (8, 5)] (let matches = find_mul example_input in extract_pairs matches ) let test_solve () = Alcotest.(check int) "" 161 @@ solve example_input let () = let open Alcotest in run "test suite for day 3 part 1" [ ( "test implementation" , [ test_case "muls extracted from example correctly" `Quick @@ test_find_mul ; test_case "pairs extracted from matches" `Quick @@ test_extract_pairs ; test_case "example correctly solved" `Quick @@ test_solve ] ) ]