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.

81 lines
1.8 KiB

11 months ago
11 months ago
11 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. void setUp(void)
  9. {
  10. }
  11. void tearDown(void)
  12. {
  13. }
  14. void test_inputHandling_deleteOneWhiteSpace(void)
  15. {
  16. deleteWhitespace(halloWelt, 10);
  17. TEST_ASSERT_EQUAL_STRING("HalloWelt", halloWelt);
  18. }
  19. void test_inputHandling_deleteTwoWhiteSpaces(void)
  20. {
  21. deleteWhitespace(halloWelt2, 11);
  22. TEST_ASSERT_EQUAL_STRING("HalloWelt", halloWelt2);
  23. }
  24. void test_inputHandling_deleteManyWhiteSpaces(void)
  25. {
  26. deleteWhitespace(halloWelt3, 16);
  27. TEST_ASSERT_EQUAL_STRING("HalloWelt", halloWelt3);
  28. }
  29. void test_inputHandling_deleteAllOtherCharacter(void)
  30. {
  31. deleteWhitespace(halloWelt4, 19);
  32. TEST_ASSERT_EQUAL_STRING("HalloWelt", halloWelt4);
  33. }
  34. void test_inputHandling_findAddFunctionType(void)
  35. {
  36. op type = opNotSupported;
  37. type = detectFunctionOperator("4+5", 3);
  38. TEST_ASSERT_TRUE(opAdd == type);
  39. }
  40. void test_inputHandling_findSubFunctionType(void)
  41. {
  42. op type = opNotSupported;
  43. type = detectFunctionOperator("4-5", 3);
  44. TEST_ASSERT_TRUE(opSub == type);
  45. }
  46. void test_inputHandling_findMultiFunctionType(void)
  47. {
  48. op type = opNotSupported;
  49. type = detectFunctionOperator("4*5", 3);
  50. TEST_ASSERT_TRUE(opMult == type);
  51. }
  52. void test_inputHandling_findDivFunctionType(void)
  53. {
  54. op type = opNotSupported;
  55. type = detectFunctionOperator("4/5", 3);
  56. TEST_ASSERT_TRUE(opDiv == type);
  57. type = opNotSupported;
  58. type = detectFunctionOperator("4:5", 3);
  59. TEST_ASSERT_TRUE(opDiv == type);
  60. }
  61. void test_inputHandling_findExpFunctionType(void)
  62. {
  63. op type = opNotSupported;
  64. type = detectFunctionOperator("4^5", 3);
  65. TEST_ASSERT_TRUE(opExp == type);
  66. }
  67. #endif // TEST