|
|
@ -15,33 +15,43 @@ void test_convert(void) { |
|
|
|
|
|
|
|
/* Arrange */ |
|
|
|
|
|
|
|
int length = 10; |
|
|
|
float euro[] = {34, 233, 400, 100, 45, 344, 767.32, 122, 435, 899}; |
|
|
|
|
|
|
|
float expectedUSD[length]; |
|
|
|
float expectedGBP[length]; |
|
|
|
|
|
|
|
float resultUSD[length]; |
|
|
|
float resultGBP[length]; |
|
|
|
|
|
|
|
for (int i = 0; i < length; i++) { |
|
|
|
expectedUSD[i] = euro[i] * USD_RATE_OF_ONE_EURO; |
|
|
|
expectedGBP[i] = euro[i] * GBP_RATE_OF_ONE_EURO; |
|
|
|
} |
|
|
|
int length = 10; |
|
|
|
float euro[] = {34, 233, 400, 100, 45, 344, 767.32, 122, 435, 899}; |
|
|
|
|
|
|
|
float expectedUSD[length]; |
|
|
|
float expectedGBP[length]; |
|
|
|
float expectedYEN[length]; |
|
|
|
float expectedYUAN[length]; |
|
|
|
|
|
|
|
float resultUSD[length]; |
|
|
|
float resultGBP[length]; |
|
|
|
float resultYEN[length]; |
|
|
|
float resultYUAN[length]; |
|
|
|
|
|
|
|
for (int i = 0; i < length; i++) { |
|
|
|
expectedUSD[i] = euro[i] * USD_RATE_OF_ONE_EURO; |
|
|
|
expectedGBP[i] = euro[i] * GBP_RATE_OF_ONE_EURO; |
|
|
|
expectedYEN[i] = euro[i] * JAPANESE_YEN_RATE_OF_ONE_EURO; |
|
|
|
expectedYUAN[i] = euro[i] * CHINESE_YUAN_RATE_OF_ONE_EURO; |
|
|
|
} |
|
|
|
|
|
|
|
/* Act */ |
|
|
|
|
|
|
|
for (int i = 0; i < length; i++) { |
|
|
|
resultUSD[i] = convert(euro[i], CURRENCY_CODE_USD); |
|
|
|
resultGBP[i] = convert(euro[i], CURRENCY_CODE_GBP); |
|
|
|
} |
|
|
|
for (int i = 0; i < length; i++) { |
|
|
|
resultUSD[i] = convert(euro[i], CURRENCY_CODE_USD); |
|
|
|
resultGBP[i] = convert(euro[i], CURRENCY_CODE_GBP); |
|
|
|
resultYEN[i] = convert(euro[i], CURRENCY_CODE_JAPANESE_YEN); |
|
|
|
resultYUAN[i] = convert(euro[i], CURRENCY_CODE_CHINESE_YUAN); |
|
|
|
} |
|
|
|
|
|
|
|
/* Assert*/ |
|
|
|
|
|
|
|
for (int i = 0; i < length; i++) { |
|
|
|
TEST_ASSERT_EQUAL_FLOAT(expectedUSD[i], resultUSD[i]); |
|
|
|
TEST_ASSERT_EQUAL_FLOAT(expectedGBP[i], resultGBP[i]); |
|
|
|
} |
|
|
|
for (int i = 0; i < length; i++) { |
|
|
|
TEST_ASSERT_EQUAL_FLOAT(expectedUSD[i], resultUSD[i]); |
|
|
|
TEST_ASSERT_EQUAL_FLOAT(expectedGBP[i], resultGBP[i]); |
|
|
|
TEST_ASSERT_EQUAL_FLOAT(expectedYEN[i], resultYEN[i]); |
|
|
|
TEST_ASSERT_EQUAL_FLOAT(expectedYUAN[i], resultYUAN[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|