0
/***********************************************************************
0
Program : Kalah game in PROLOG
0
File : test_fixtures.pl
0
Description : unit tests
0
***********************************************************************/
0
/***********************************************************************
0
***********************************************************************/
0
-tests(utils/in_range, [
0
- in_range__when_given_correct_input__satisfied,
0
- in_range__when_equal_to_min__satisfied,
0
- in_range__when_equal_to_max__satisfied,
0
- in_range__when_given_out_of_range_input__dissatisfied
0
+tests(utils/is_in_range, [
0
+ is_in_range__when_given_correct_input__satisfied,
0
+ is_in_range__when_equal_to_min__satisfied,
0
+ is_in_range__when_equal_to_max__satisfied,
0
+ is_in_range__when_given_out_of_range_input__dissatisfied
0
-in_range__when_given_correct_input__satisfied :-
0
+is_in_range__when_given_correct_input__satisfied :-
0
-in_range__when_equal_to_min__satisfied :-
0
+is_in_range__when_equal_to_min__satisfied :-
0
-in_range__when_equal_to_max__satisfied :-
0
+is_in_range__when_equal_to_max__satisfied :-
0
-in_range__when_given_out_of_range_input__dissatisfied :-
0
+is_in_range__when_given_out_of_range_input__dissatisfied :-
0
+ not is_in_range(4, 1-3).
0
+/***********************************************************************
0
+***********************************************************************/
0
+tests(utils/in_range, [
0
+ in_range__when_given_correct_input__generates,
0
+ in_range__when_given_incorrect_input__fails
0
+in_range__when_given_correct_input__generates :-
0
+ bagof(X, in_range(X, 1-3), Xs),
0
+in_range__when_given_incorrect_input__fails :-
0
+ not bagof(X, in_range(X, 3-1), _).
0
+/***********************************************************************
0
+***********************************************************************/
0
tests(utils/create_list, [
0
create_list__always__creates_the_list_with_the_correct_data,
0
create_list__always__creates_the_list_with_the_correct_length
0
@@ -49,9 +64,33 @@ create_list__always__creates_the_list_with_the_correct_length :-
0
/***********************************************************************
0
***********************************************************************/
0
+ conc__empty_and_empty__return_empty,
0
+ conc__empty_and_nonempty__return_L2,
0
+ conc__nonempty_and_empty__return_L1,
0
+ conc__nonempty_and_nonempty__return_L1concL2
0
+conc__empty_and_empty__return_empty :-
0
+conc__empty_and_nonempty__return_L2 :-
0
+ conc([], [1,2], [1,2]).
0
+conc__nonempty_and_empty__return_L1 :-
0
+ conc([1,2], [], [1,2]).
0
+conc__nonempty_and_nonempty__return_L1concL2 :-
0
+ conc([1,2], [3,4], [1,2,3,4]).
0
+/***********************************************************************
0
+***********************************************************************/
0
tests(moves/change_list, [
0
change_list__add_first__works,
0
change_list__add_middle__works,
0
@@ -94,9 +133,8 @@ change_list__add_last__works :-
0
/***********************************************************************
0
***********************************************************************/
0
move__when_ends_within_same_player_pits__works
0
@@ -109,9 +147,8 @@ move__when_ends_within_same_player_pits__works :-
0
/***********************************************************************
0
***********************************************************************/
0
step__when_ends_within_same_player_pits__works,
0
step__when_ends_within_next_player_pits__works
0
@@ -120,15 +157,12 @@ tests(moves/step, [
0
step__when_ends_within_same_player_pits__works :-
0
P1P=pits(player1,0,0,0,0),
0
P2P=pits(player2,0,0,0,0),
0
- step(P1P/P2P, Last, 0, NewP1P/P2P, _, _),
0
+ step(P1P/P2P, player1/1, 1, NewP1P/P2P, _, _),
0
NewP1P=pits(player1,0,1,0,0).
0
step__when_ends_within_next_player_pits__works :-
0
P1P=pits(player1,0,0,0,0),
0
P2P=pits(player2,0,0,0,0),
0
- step(P1P/P2P, Last, 4, NewP1P/NewP2P, _, _),
0
+ step(P1P/P2P, player1/1, 4, NewP1P/NewP2P, _, _),
0
NewP1P=pits(player1,0,1,1,1),
0
NewP2P=pits(player2,1,0,0,0).
Comments
No one has commented yet.