|
@ -0,0 +1,49 @@ |
|
|
|
|
|
#include "../src/operationHandler.h" |
|
|
|
|
|
#include "unity.h" |
|
|
|
|
|
|
|
|
|
|
|
void setUp(void) { |
|
|
|
|
|
// set stuff up here |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void tearDown(void) { |
|
|
|
|
|
// clean stuff up here |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_operationHandler_truereturnvaluewithvalidinput(void) { |
|
|
|
|
|
int expectedResult = 1; |
|
|
|
|
|
int result1 = checkOperationInput(1); |
|
|
|
|
|
int result2 = checkOperationInput(2); |
|
|
|
|
|
int result3 = checkOperationInput(3); |
|
|
|
|
|
int result4 = checkOperationInput(4); |
|
|
|
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, result1); |
|
|
|
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, result2); |
|
|
|
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, result3); |
|
|
|
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, result4); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_operationHandler_falsereturnvaluewithinvalidinput(void) { |
|
|
|
|
|
int expectedResult = 0; |
|
|
|
|
|
int result = checkOperationInput(8); |
|
|
|
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_operationHandler_truereturnvaluewithformattedinput(void) { |
|
|
|
|
|
int expectedResult = 1; |
|
|
|
|
|
const char str[] = {'1', '4', ' ', '5', '6', '\0'}; |
|
|
|
|
|
int result = containsTwoNumbers(str); |
|
|
|
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_operationHandler_falsereturnvaluewithwronginput(void) { |
|
|
|
|
|
int expectedResult = 0; |
|
|
|
|
|
const char str[] = {'5', '6', '\0'}; |
|
|
|
|
|
int result = containsTwoNumbers(str); |
|
|
|
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_operationHandler_extractingFirstNumber(void) { |
|
|
|
|
|
int expectedResult = 48; |
|
|
|
|
|
char str[] = {'4', '8', ' ', '5', '\0'}; |
|
|
|
|
|
int result = extractFirstNumber(str); |
|
|
|
|
|
TEST_ASSERT_EQUAL_INT(expectedResult, result); |
|
|
|
|
|
} |