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.
64 lines
971 B
64 lines
971 B
#ifdef TEST
|
|
|
|
#include "unity.h"
|
|
|
|
#include "currentCustomerAccountBalance.h"
|
|
|
|
void setUp(void)
|
|
{
|
|
}
|
|
|
|
void tearDown(void)
|
|
{
|
|
}
|
|
|
|
void test_fetchBalanceFromBalanceString(void) {
|
|
char balanceString[5][100] = {
|
|
"balance=0",
|
|
"balance=100",
|
|
"balance=200",
|
|
"balance=300",
|
|
"balance=400"
|
|
};
|
|
|
|
float balance = 0;
|
|
float result[5];
|
|
float expected[5];
|
|
|
|
for (int i = 0; i < 5; i++) {
|
|
result[i] = fetchBalanceFromBalanceString(balanceString[i]);
|
|
}
|
|
|
|
for (int i = 0; i < 5; i++) {
|
|
expected[i] = balance;
|
|
balance += 100;
|
|
}
|
|
|
|
for (int i =0; i < 5; i++) {
|
|
TEST_ASSERT_EQUAL_FLOAT(expected[i],result[i]);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
void test_checkFileOpen(void) {
|
|
|
|
FILE *file = fopen(CUSTOMER_DATA_FILE, "r");
|
|
|
|
TEST_ASSERT_TRUE(file);
|
|
|
|
fclose(file);
|
|
}
|
|
|
|
void test_failOpenFile(void) {
|
|
FILE *file = fopen("false_file_name", "r");
|
|
|
|
TEST_ASSERT_FALSE(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // TEST
|