blob: 4feea41c68d271f525290d807528b55d07348839 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
open Year2024.Day02.Part01
let test_solve have want () =
Alcotest.(check int) "incorrect solution" want @@ solve have
let test_report_safety_check have want () =
Alcotest.(check bool) "incorrect report safety" want
@@ check_report_safety have
let () =
let open Alcotest in
run "test suite for day 2 part 1"
[ ( "test solutions"
, [ test_case "empty list should have no valid reports" `Quick
@@ test_solve [] 0
; test_case "valid report should count as one" `Quick
@@ test_solve [[7; 6; 4; 2; 1]] 1
; test_case "provided example" `Quick
@@ test_solve
[ [7; 6; 4; 2; 1]
; [1; 2; 7; 8; 9]
; [9; 7; 6; 2; 1]
; [1; 3; 2; 4; 5]
; [8; 6; 4; 4; 1]
; [1; 3; 6; 7; 9] ]
2 ] )
; ( "test report safety check"
, [ test_case "all increasing" `Quick
@@ test_report_safety_check [1; 2; 3] true
; test_case "all decreasing" `Quick
@@ test_report_safety_check [3; 2; 1] true
; test_case "increasing and decreasing" `Quick
@@ test_report_safety_check [1; 3; 2] false
; test_case "change of at least one" `Quick
@@ test_report_safety_check [1; 2; 3] true
; test_case "no change" `Quick
@@ test_report_safety_check [1; 1; 2] false
; test_case "change of at most three" `Quick
@@ test_report_safety_check [1; 2; 4; 7] true
; test_case "change of at more than three" `Quick
@@ test_report_safety_check [1; 5] false ] ) ]
|