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.

72 lines
1.1 KiB

  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "currencyExchange.h"
  4. void setUp(void)
  5. {
  6. }
  7. void tearDown(void)
  8. {
  9. }
  10. void test_toUSD(void) {
  11. /* Arrange */
  12. int length = 5;
  13. float euro[] = {34, 233, 400, 100, 45};
  14. float expectedUSD[length];
  15. float resultUSD[length];
  16. for (int i = 0; i < length; i++) {
  17. resultUSD[i] = toUSD(euro[i]);
  18. }
  19. /* Act */
  20. for (int i = 0; i < length; i++) {
  21. expectedUSD[i] = euro[i] * CURRENT_USD_RATE_OF_ONE_EURO;
  22. }
  23. /* Assert */
  24. for (int i = 0; i < length; i++) {
  25. TEST_ASSERT_EQUAL_FLOAT(expectedUSD[i], resultUSD[i]);
  26. }
  27. }
  28. void test_toGBP(void) {
  29. /* Arrange */
  30. int length = 5;
  31. float euro[] = {34, 233, 400, 100, 45};
  32. float expectedGBP[length];
  33. float resultGBP[length];
  34. for (int i = 0; i < length; i++) {
  35. resultGBP[i] = toGBP(euro[i]);
  36. }
  37. /* Act */
  38. for (int i = 0; i < length; i++) {
  39. expectedGBP[i] = euro[i] * CURRENT_GBP_RATE_OF_ONE_EURO;
  40. }
  41. /* Assert */
  42. for (int i = 0; i < length; i++) {
  43. TEST_ASSERT_EQUAL_FLOAT(expectedGBP[i], resultGBP[i]);
  44. }
  45. }
  46. #endif // TEST