diff --git a/tests/test_currentCustomerAccountBalance.c b/tests/test_currentCustomerAccountBalance.c index 4855135..50888db 100644 --- a/tests/test_currentCustomerAccountBalance.c +++ b/tests/test_currentCustomerAccountBalance.c @@ -13,6 +13,9 @@ void tearDown(void) } void test_fetchBalanceFromBalanceString(void) { + + /* Arrange */ + char balanceString[5][100] = { "balance=0", "balance=100", @@ -21,6 +24,8 @@ void test_fetchBalanceFromBalanceString(void) { "balance=400" }; + /* Act */ + float balance = 0; float result[5]; float expected[5]; @@ -29,6 +34,8 @@ void test_fetchBalanceFromBalanceString(void) { result[i] = fetchBalanceFromBalanceString(balanceString[i]); } + /* Assert */ + for (int i = 0; i < 5; i++) { expected[i] = balance; balance += 100; @@ -44,6 +51,8 @@ void test_fetchBalanceFromBalanceString(void) { void test_checkFileOpen(void) { + /* Act and assert */ + FILE *file = fopen(CUSTOMER_DATA_FILE, "r"); TEST_ASSERT_TRUE(file); @@ -52,6 +61,9 @@ void test_checkFileOpen(void) { } void test_failOpenFile(void) { + + /* Act and assert */ + FILE *file = fopen("false_file_name", "r"); TEST_ASSERT_FALSE(file); @@ -59,11 +71,14 @@ void test_failOpenFile(void) { } void test_getAvailableAccountBalance(void) { - int user_id = 1234; + + /* Act and assert */ + + int user_id = 1234; // Random user_id (because idea is to read the file and get a float value) float max = FLT_MAX; int result = getAvailableAccountBalance(user_id); - TEST_ASSERT_TRUE(result < max); + TEST_ASSERT_TRUE(result < max); // Pass if function is successfully called and a float value (balance) is returned }