You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.7 KiB

  1. #include "../src/operationHandler.h"
  2. #include "unity.h"
  3. void setUp(void) {
  4. // set stuff up here
  5. }
  6. void tearDown(void) {
  7. // clean stuff up here
  8. }
  9. void test_operationHandler_truereturnvaluewithvalidinput(void) {
  10. int expectedResult = 1;
  11. int result1 = checkOperationInput(1);
  12. int result2 = checkOperationInput(2);
  13. int result3 = checkOperationInput(3);
  14. int result4 = checkOperationInput(4);
  15. TEST_ASSERT_EQUAL_INT(expectedResult, result1);
  16. TEST_ASSERT_EQUAL_INT(expectedResult, result2);
  17. TEST_ASSERT_EQUAL_INT(expectedResult, result3);
  18. TEST_ASSERT_EQUAL_INT(expectedResult, result4);
  19. }
  20. void test_operationHandler_falsereturnvaluewithinvalidinput(void) {
  21. int expectedResult = 0;
  22. int result = checkOperationInput(8);
  23. TEST_ASSERT_EQUAL_INT(expectedResult, result);
  24. }
  25. void test_operationHandler_truereturnvaluewithformattedinput(void) {
  26. int expectedResult = 1;
  27. const char str[] = {'1', '4', ' ', '5', '6', '\0'};
  28. int result = containsTwoNumbers(str);
  29. TEST_ASSERT_EQUAL_INT(expectedResult, result);
  30. }
  31. void test_operationHandler_falsereturnvaluewithwronginput(void) {
  32. int expectedResult = 0;
  33. const char str[] = {'5', '6', '\0'};
  34. int result = containsTwoNumbers(str);
  35. TEST_ASSERT_EQUAL_INT(expectedResult, result);
  36. }
  37. void test_operationHandler_extractingFirstNumber(void) {
  38. int expectedResult = 48;
  39. char str[] = {'4', '8', ' ', '5', '\0'};
  40. int result = extractFirstNumber(str);
  41. TEST_ASSERT_EQUAL_INT(expectedResult, result);
  42. }
  43. void test_operationHandler_removefirstnumberfromoriginalstring(void) {
  44. char expected[] = {'5', '\0'};
  45. char str[] = {'4', '8', ' ', '5', '\0'};
  46. extractFirstNumber(str);
  47. TEST_ASSERT_EQUAL_STRING(expected, str);
  48. }