Browse Source

Create unit test for failed deposits

main
fdlt3817 2 years ago
parent
commit
9c16e03799
  1. 25
      tests/test_depositMoney.c

25
tests/test_depositMoney.c

@ -32,5 +32,30 @@ void test_depositSpecificAmount(void) {
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
TEST_ASSERT_TRUE(result[i]); TEST_ASSERT_TRUE(result[i]);
} }
}
void test_depositSpecificAmountFail(void) {
/* Arrange */
int length = 5;
int userIDs[] = {1234,1235,1236,1237,1238};
float amountToDeposit[] = {-23, -3, -234, -23, -400};
bool result[length];
/* Act */
for (int i = 0; i < length; i++) {
result[i] = depositSpecificAmount( userIDs[i], amountToDeposit[i] );
}
/* Assert */
for (int i = 0; i < length; i++) {
TEST_ASSERT_FALSE(result[i]);
}
} }
Loading…
Cancel
Save