Browse Source

Create test for invalid interests

main
fdlt3817 2 years ago
parent
commit
336ab0aea9
  1. 37
      tests/test_interestCalculator.c

37
tests/test_interestCalculator.c

@ -46,5 +46,40 @@ void test_initiateInterest(void) {
} }
} }
void test_initiateInterestFalse(void) {
#endif // TEST
/* Arrange */
int length = 10;
float startAmount[] = {34, 233, 4400, 1600, 245, 34544, 3767.32, 1422, 5435, 8199};
float yearlyInterest=12;
float durationInYears=2.5;
float monthlyInterest=8;
float durationInMonths=3.9;
float resultsYearly[length];
float resultsMonthly[length];
float expectedYearly[]={0,0,0,0,0,0,0,0,0,0};
float expectedMonthly[]={0,0,0,0,0,0,0,0,0,0};
/* Act */
for (int i = 0; i < length; i++) {
resultsYearly[i]=initiateInterest(startAmount[i],yearlyInterest/100, durationInYears);
}
for (int i = 0; i < length; i++) {
resultsMonthly[i]=initiateInterest(startAmount[i],monthlyInterest/100, durationInMonths);
}
/* Assert*/
for (int i = 0; i < length; i++) {
TEST_ASSERT_FALSE(expectedYearly[i] == resultsYearly[i]);
TEST_ASSERT_FALSE(expectedMonthly[i] == resultsMonthly[i]);
}
}
#endif // TEST
Loading…
Cancel
Save