Browse Source

Refactoring: organise code

remotes/origin/feature/currency-exchange
Shivam Chaudhary 2 years ago
parent
commit
984c860e0d
  1. 10
      tests/test_currencyExchange.c

10
tests/test_currencyExchange.c

@ -12,8 +12,12 @@ void tearDown(void)
} }
void test_toUSD(void) { void test_toUSD(void) {
int length = 5;
/* Arrange */
int length = 5;
float euro[] = {34, 233, 400, 100, 45}; float euro[] = {34, 233, 400, 100, 45};
float expectedUSD[length]; float expectedUSD[length];
float resultUSD[length]; float resultUSD[length];
@ -21,10 +25,14 @@ void test_toUSD(void) {
resultUSD[i] = toUSD(euro[i]); resultUSD[i] = toUSD(euro[i]);
} }
/* Act */
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
expectedUSD[i] = euro[i] * CURRENT_USD_RATE_OF_ONE_EURO; expectedUSD[i] = euro[i] * CURRENT_USD_RATE_OF_ONE_EURO;
} }
/* Assert */
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
TEST_ASSERT_EQUAL_FLOAT(expectedUSD[i], resultUSD[i]); TEST_ASSERT_EQUAL_FLOAT(expectedUSD[i], resultUSD[i]);
} }

Loading…
Cancel
Save