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.

96 lines
2.2 KiB

12 months ago
12 months ago
12 months ago
  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "inputHandling.h"
  4. char halloWelt[]="Hallo Welt";
  5. char halloWelt2[]="Hallo Welt";
  6. char halloWelt3[]="Ha llo W el t ";
  7. char halloWelt4[]="Ha\n\nllo \r W el\r\r t ";
  8. calc_op formula = {0};
  9. void setUp(void)
  10. {
  11. formula.functionsType = opNotSupported;
  12. }
  13. void tearDown(void)
  14. {
  15. }
  16. void test_inputHandling_deleteOneWhiteSpace(void)
  17. {
  18. deleteWhitespace(halloWelt, 10);
  19. TEST_ASSERT_EQUAL_STRING("HalloWelt", halloWelt);
  20. }
  21. void test_inputHandling_deleteTwoWhiteSpaces(void)
  22. {
  23. deleteWhitespace(halloWelt2, 11);
  24. TEST_ASSERT_EQUAL_STRING("HalloWelt", halloWelt2);
  25. }
  26. void test_inputHandling_deleteManyWhiteSpaces(void)
  27. {
  28. deleteWhitespace(halloWelt3, 16);
  29. TEST_ASSERT_EQUAL_STRING("HalloWelt", halloWelt3);
  30. }
  31. void test_inputHandling_deleteAllOtherCharacter(void)
  32. {
  33. deleteWhitespace(halloWelt4, 19);
  34. TEST_ASSERT_EQUAL_STRING("HalloWelt", halloWelt4);
  35. }
  36. void test_inputHandling_findAddFunctionType(void)
  37. {
  38. op type = opNotSupported;
  39. type = detectFunctionOperator("4+5", 3);
  40. TEST_ASSERT_TRUE(opAdd == type);
  41. }
  42. void test_inputHandling_findSubFunctionType(void)
  43. {
  44. op type = opNotSupported;
  45. type = detectFunctionOperator("4-5", 3);
  46. TEST_ASSERT_TRUE(opSub == type);
  47. }
  48. void test_inputHandling_findMultiFunctionType(void)
  49. {
  50. op type = opNotSupported;
  51. type = detectFunctionOperator("4*5", 3);
  52. TEST_ASSERT_TRUE(opMult == type);
  53. }
  54. void test_inputHandling_findDivFunctionType(void)
  55. {
  56. op type = opNotSupported;
  57. type = detectFunctionOperator("4/5", 3);
  58. TEST_ASSERT_TRUE(opDiv == type);
  59. type = opNotSupported;
  60. type = detectFunctionOperator("4:5", 3);
  61. TEST_ASSERT_TRUE(opDiv == type);
  62. }
  63. void test_inputHandling_findExpFunctionType(void)
  64. {
  65. op type = opNotSupported;
  66. type = detectFunctionOperator("4^5", 3);
  67. TEST_ASSERT_TRUE(opExp == type);
  68. }
  69. void test_inputHandling_findEmptyFunctionType(void)
  70. {
  71. op type = opNotSupported;
  72. type = detectFunctionOperator(halloWelt, 10);
  73. TEST_ASSERT_TRUE(opEmpty == type);
  74. }
  75. void test_inputHandling_getNumbersNoFormular(void)
  76. {
  77. char* pnt = NULL;
  78. pnt = getNumbers(halloWelt, 10, &formula);
  79. TEST_ASSERT_NULL(pnt);
  80. }
  81. #endif // TEST