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.

57 lines
858 B

  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "currentCustomerAccountBalance.h"
  4. void setUp(void)
  5. {
  6. }
  7. void tearDown(void)
  8. {
  9. }
  10. void test_fetchBalanceFromBalanceString(void) {
  11. char balanceString[5][100] = {
  12. "balance=0",
  13. "balance=100",
  14. "balance=200",
  15. "balance=300",
  16. "balance=400"
  17. };
  18. float balance = 0;
  19. float result[5];
  20. float expected[5];
  21. for (int i = 0; i < 5; i++) {
  22. result[i] = fetchBalanceFromBalanceString(balanceString[i]);
  23. }
  24. for (int i = 0; i < 5; i++) {
  25. expected[i] = balance;
  26. balance += 100;
  27. }
  28. for (int i =0; i < 5; i++) {
  29. TEST_ASSERT_EQUAL_FLOAT(expected[i],result[i]);
  30. }
  31. }
  32. void test_checkFileOpen(void) {
  33. FILE *file = fopen(CUSTOMER_DATA_FILE, "r");
  34. TEST_ASSERT_TRUE(file);
  35. fclose(file);
  36. }
  37. #endif // TEST