View raw

1 (** The list helpers in {!Ogit.List_ext}. *) 2 3 let list_int = Alcotest.(list int) 4 5 let test_take () = 6 Alcotest.check list_int "take 0" [] (Ogit.List_ext.take 0 [ 1; 2; 3 ]); 7 Alcotest.check list_int "take 2" [ 1; 2 ] (Ogit.List_ext.take 2 [ 1; 2; 3 ]); 8 Alcotest.check list_int "take all" [ 1; 2; 3 ] 9 (Ogit.List_ext.take 3 [ 1; 2; 3 ]); 10 Alcotest.check list_int "take beyond" [ 1; 2; 3 ] 11 (Ogit.List_ext.take 5 [ 1; 2; 3 ]); 12 Alcotest.check list_int "take from empty" [] (Ogit.List_ext.take 3 []); 13 Alcotest.check list_int "take negative" [] (Ogit.List_ext.take (-1) [ 1; 2 ]) 14 15 let test_drop () = 16 Alcotest.check list_int "drop 0" [ 1; 2; 3 ] 17 (Ogit.List_ext.drop 0 [ 1; 2; 3 ]); 18 Alcotest.check list_int "drop 2" [ 3 ] (Ogit.List_ext.drop 2 [ 1; 2; 3 ]); 19 Alcotest.check list_int "drop all" [] (Ogit.List_ext.drop 3 [ 1; 2; 3 ]); 20 Alcotest.check list_int "drop beyond" [] (Ogit.List_ext.drop 5 [ 1; 2; 3 ]); 21 Alcotest.check list_int "drop from empty" [] (Ogit.List_ext.drop 3 []); 22 Alcotest.check list_int "drop negative" [ 1; 2 ] 23 (Ogit.List_ext.drop (-1) [ 1; 2 ]) 24 25 let suite = 26 ( "list_ext", 27 [ 28 Alcotest.test_case "take" `Quick test_take; 29 Alcotest.test_case "drop" `Quick test_drop; 30 ] ) 31