|
@ -2,6 +2,10 @@ |
|
|
#include "unity.h" |
|
|
#include "unity.h" |
|
|
#include <stdlib.h> |
|
|
#include <stdlib.h> |
|
|
|
|
|
|
|
|
|
|
|
const int scissor = 1; |
|
|
|
|
|
const int rock = 2; |
|
|
|
|
|
const int paper = 3; |
|
|
|
|
|
|
|
|
void setUp(void) |
|
|
void setUp(void) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
@ -19,7 +23,7 @@ void test_draw_USER_Scissor_COM_Scissor() |
|
|
//arrange |
|
|
//arrange |
|
|
int expectedResult = 0; |
|
|
int expectedResult = 0; |
|
|
//act |
|
|
//act |
|
|
int actualResult = calculateWinner(1,1); |
|
|
|
|
|
|
|
|
int actualResult = calculateWinner(scissor,scissor); |
|
|
//assert |
|
|
//assert |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
} |
|
|
} |
|
@ -29,7 +33,7 @@ void test_draw_USER_Rock_COM_Rock() |
|
|
//arrange |
|
|
//arrange |
|
|
int expectedResult = 0; |
|
|
int expectedResult = 0; |
|
|
//act |
|
|
//act |
|
|
int actualResult = calculateWinner(2,2); |
|
|
|
|
|
|
|
|
int actualResult = calculateWinner(rock,rock); |
|
|
//assert |
|
|
//assert |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
} |
|
|
} |
|
@ -39,7 +43,7 @@ void test_draw_USER_Paper_COM_Paper() |
|
|
//arrange |
|
|
//arrange |
|
|
int expectedResult = 0; |
|
|
int expectedResult = 0; |
|
|
//act |
|
|
//act |
|
|
int actualResult = calculateWinner(3,3); |
|
|
|
|
|
|
|
|
int actualResult = calculateWinner(paper,paper); |
|
|
//assert |
|
|
//assert |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
} |
|
|
} |
|
@ -52,7 +56,7 @@ void test_lose_USER_Scissor_COM_Rock() |
|
|
//arrange |
|
|
//arrange |
|
|
int expectedResult = -1; |
|
|
int expectedResult = -1; |
|
|
//act |
|
|
//act |
|
|
int actualResult = calculateWinner(1,2); |
|
|
|
|
|
|
|
|
int actualResult = calculateWinner(scissor,rock); |
|
|
//assert |
|
|
//assert |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
} |
|
|
} |
|
@ -62,7 +66,7 @@ void test_lose_USER_Paper_COM_Scissor() |
|
|
//arrange |
|
|
//arrange |
|
|
int expectedResult = -1; |
|
|
int expectedResult = -1; |
|
|
//act |
|
|
//act |
|
|
int actualResult = calculateWinner(3,1); |
|
|
|
|
|
|
|
|
int actualResult = calculateWinner(paper,scissor); |
|
|
//assert |
|
|
//assert |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
} |
|
|
} |
|
@ -72,7 +76,7 @@ void test_lose_USER_Rock_COM_Paper() |
|
|
//arrange |
|
|
//arrange |
|
|
int expectedResult = -1; |
|
|
int expectedResult = -1; |
|
|
//act |
|
|
//act |
|
|
int actualResult = calculateWinner(2,3); |
|
|
|
|
|
|
|
|
int actualResult = calculateWinner(rock,paper); |
|
|
//assert |
|
|
//assert |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
} |
|
|
} |
|
@ -85,7 +89,7 @@ void test_win_USER_Scissor_COM_Paper() |
|
|
//arrange |
|
|
//arrange |
|
|
int expectedResult = 1; |
|
|
int expectedResult = 1; |
|
|
//act |
|
|
//act |
|
|
int actualResult = calculateWinner(1,3); |
|
|
|
|
|
|
|
|
int actualResult = calculateWinner(scissor,paper); |
|
|
//assert |
|
|
//assert |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
} |
|
|
} |
|
@ -95,7 +99,7 @@ void test_win_USER_Rock_COM_Scissor() |
|
|
//arrange |
|
|
//arrange |
|
|
int expectedResult = 1; |
|
|
int expectedResult = 1; |
|
|
//act |
|
|
//act |
|
|
int actualResult = calculateWinner(2,1); |
|
|
|
|
|
|
|
|
int actualResult = calculateWinner(rock,scissor); |
|
|
//assert |
|
|
//assert |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
} |
|
|
} |
|
@ -105,7 +109,7 @@ void test_win_USER_Paper_COM_Rock() |
|
|
//arrange |
|
|
//arrange |
|
|
int expectedResult = 1; |
|
|
int expectedResult = 1; |
|
|
//act |
|
|
//act |
|
|
int actualResult = calculateWinner(3,2); |
|
|
|
|
|
|
|
|
int actualResult = calculateWinner(paper,rock); |
|
|
//assert |
|
|
//assert |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); |
|
|
} |
|
|
} |
|
|