File size: 3,473 Bytes
24e07f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
45
46
47
48
49
50
51

module Main = struct
    open OUnit2

    (* Program start *)

    (* Program end *)

    (* Test cases *)
    
let test1 _ = assert_equal true (hasIncreasingSubarrays [2;5;7;8;9;2;3;4;3;1] 3)

let test2 _ = assert_equal false (hasIncreasingSubarrays [1;2;3;4;4;4;4;5;6;7] 5)

let test3 _ = assert_equal false (hasIncreasingSubarrays [-669; 939; ( -671); ( -764); ( -122); 65; 433; ( -158); 532; ( -539); 634; ( -912); ( -271); 596; 397; 732; ( -474); 665; 518; 851; 3; 290; ( -172); ( -303); ( -856); 594; ( -99); 265; ( -948); ( -66); 381; ( -217); 765; 992; ( -799); ( -962); ( -359); ( -116); ( -737); ( -271); 441; 552; ( -845); ( -663); ( -415); 23; 987] 20)

let test4 _ = assert_equal false (hasIncreasingSubarrays [846; ( -627); 915; ( -300); ( -391); ( -505); 507] 2)

let test5 _ = assert_equal false (hasIncreasingSubarrays [871; ( -896); ( -232); 537; 464; 728; ( -10); ( -927); ( -539); ( -113); 928; 555; 775; ( -900); ( -289); 795; ( -849); 450; 253; 450; ( -308); ( -589); ( -563); 848; 119; ( -780); ( -381)] 5)

let test6 _ = assert_equal false (hasIncreasingSubarrays [0; ( -807); 367; 485; 105; 174; ( -444); ( -479); ( -440); ( -626); ( -645); 422; 608; 881; ( -2); 147; ( -796); ( -752); 799; ( -782); ( -281); ( -955); ( -700); ( -946); ( -175); 134; 738; ( -983); 441; 284; 545; ( -597); ( -168); ( -53); 702; ( -845); ( -34); 126; ( -351); 842; 257; 59; 821; ( -974); 546; ( -628); ( -55); ( -452); 203; ( -793); ( -251); ( -515); 284] 16)

let test7 _ = assert_equal false (hasIncreasingSubarrays [-256; ( -176); 324; ( -573); ( -964); ( -489); ( -141); 884; ( -44); 137; 492; 813; ( -442); 608; ( -455); 971; ( -200); 940; 772; 359; ( -886); ( -454); ( -148); ( -473); ( -344); 18; 292; 137; ( -893); 238; ( -706); 974; ( -980); ( -639); ( -51); 267] 6)

let test8 _ = assert_equal false (hasIncreasingSubarrays [-744; 380; 344; 139; 841; 750; 102; ( -653); ( -428); ( -138); 104; 987; 604; ( -83); ( -428); ( -414); 664; ( -601); 663; ( -907); 190; 180; 926; ( -533); ( -872)] 3)

let test9 _ = assert_equal false (hasIncreasingSubarrays [945; ( -656); 548; ( -31); 150; 186; 646; ( -910); 998; 336; 297; ( -267); 255; 748; ( -171); 488; ( -426); 826; ( -497); ( -228); 558; ( -875); 606; ( -372); ( -83); ( -63); ( -639); 195; 747; ( -795); ( -198); 102; 187; ( -546); ( -325); 414; 839; 890; 959; ( -581); ( -662); 365; 369; 12; ( -955); ( -657); ( -199); 56; ( -141); 382; ( -892); ( -461); 259; ( -574); ( -677); ( -211); ( -170); 889; ( -221); 462; 901; 291; 588; 863; 193; 376; ( -358); ( -677); 620; ( -717); 782; 813; ( -329); ( -424); ( -901)] 18)

let test10 _ = assert_equal true (hasIncreasingSubarrays [-344; 743; 491; 216; 42; ( -955); ( -472); ( -736); 582; ( -552); 814; 538; 35; ( -988); 971; 362; 227; ( -42); 709; ( -704); ( -529); ( -537); 172; 609; 217; ( -73); ( -444); 67; ( -820); ( -687); ( -158); 738; 605; 804; ( -779); 463; ( -677); 491; ( -459); ( -479); ( -856); 680; ( -499); ( -349); ( -864); ( -462); 359; 119; ( -916); 43; 699; ( -488); 325; 559; 487; 151; 595; 425; ( -785); 706; 390; 215; ( -883); ( -693); 446] 3)


    (* Grouping test cases *)
    let suite = "Test Suite for hasIncreasingSubarrays" >::: [
        
  "test1" >:: test1;
  "test2" >:: test2;
  "test3" >:: test3;
  "test4" >:: test4;
  "test5" >:: test5;
  "test6" >:: test6;
  "test7" >:: test7;
  "test8" >:: test8;
  "test9" >:: test9;
  "test10" >:: test10;
    ]


    (* Running the tests *)
    let () = run_test_tt_main suite
end