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.

47 lines
903 B

  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_convert(void) {
  11. /* Arrange */
  12. int length = 10;
  13. float euro[] = {34, 233, 400, 100, 45, 344, 767.32, 122, 435, 899};
  14. float expectedUSD[length];
  15. float expectedGBP[length];
  16. float resultUSD[length];
  17. float resultGBP[length];
  18. for (int i = 0; i < length; i++) {
  19. expectedUSD[i] = euro[i] * USD_RATE_OF_ONE_EURO;
  20. expectedGBP[i] = euro[i] * GBP_RATE_OF_ONE_EURO;
  21. }
  22. /* Act */
  23. for (int i = 0; i < length; i++) {
  24. resultUSD[i] = convert(euro[i], CURRENCY_CODE_USD);
  25. resultGBP[i] = convert(euro[i], CURRENCY_CODE_GBP);
  26. }
  27. /* Assert*/
  28. for (int i = 0; i < length; i++) {
  29. TEST_ASSERT_EQUAL_FLOAT(expectedUSD[i], resultUSD[i]);
  30. TEST_ASSERT_EQUAL_FLOAT(expectedGBP[i], resultGBP[i]);
  31. }
  32. }
  33. #endif // TEST