From 0b3612d66ff79dfacf5516d610807b35b764e4b0 Mon Sep 17 00:00:00 2001 From: DJ O'Leary Date: Sat, 13 Dec 2025 03:58:26 +0100 Subject: test(2025d3): fix property test --- 2025/ocaml/test/domain/test_d03p01.ml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to '2025/ocaml') diff --git a/2025/ocaml/test/domain/test_d03p01.ml b/2025/ocaml/test/domain/test_d03p01.ml index 4832e9b..6a2b3cf 100644 --- a/2025/ocaml/test/domain/test_d03p01.ml +++ b/2025/ocaml/test/domain/test_d03p01.ml @@ -7,24 +7,20 @@ let test_highest_joltage have want () = let largest_digit_always_in_highest_joltage = QCheck2.Test.make ~count:1000 - ~name: - "highest joltage always has the largest number first unless the largest \ - digit in the input is the final digit or there are less than 3 digits" + ~name:"highest joltage always has contains the largest digit" ~print:(fun s -> s) QCheck2.Gen.(string_of @@ char_range '1' '9') (fun have -> QCheck2.assume (String.length have > 2) ; - let got = - BatteryBank.of_string have |> BatteryBank.highest_joltage - |> fun x -> x / 10 - in + let got = BatteryBank.of_string have |> BatteryBank.highest_joltage in + let first = got / 10 and second = got mod 10 in let want = String.fold_left (fun acc chr -> if acc < chr then chr else acc) '0' have |> Char.escaped |> int_of_string in - got = want ) + first = want || second = want ) let () = let open Alcotest in @@ -857,5 +853,5 @@ let () = (test_highest_joltage "0067600" 76) ] ) ; ( "BatteryBank property tests" , List.map - (QCheck_alcotest.to_alcotest ~colors:true ~speed_level:`Quick) + (QCheck_alcotest.to_alcotest ~colors:true) [largest_digit_always_in_highest_joltage] ) ] -- cgit v1.2.3