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.
48 lines
925 B
48 lines
925 B
#ifdef TEST
|
|
|
|
#include "unity.h"
|
|
#include "currencyExchange.h"
|
|
|
|
void setUp(void)
|
|
{
|
|
}
|
|
|
|
void tearDown(void)
|
|
{
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
/* Act */
|
|
|
|
for (int i = 0; i < length; i++) {
|
|
resultUSD[i] = convert(euro[i], CURRENCY_CODE_USD);
|
|
resultGBP[i] = convert(euro[i], CURRENCY_CODE_GBP);
|
|
}
|
|
|
|
/* Assert*/
|
|
|
|
for (int i = 0; i < length; i++) {
|
|
TEST_ASSERT_EQUAL_FLOAT(expectedUSD[i], resultUSD[i]);
|
|
TEST_ASSERT_EQUAL_FLOAT(expectedGBP[i], resultGBP[i]);
|
|
}
|
|
}
|
|
|
|
|
|
#endif // TEST
|