Skip to content

Commit

Permalink
Add explicit tests for FFF_RESET_CALLED_FAKES
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiefGokhlayeh committed Nov 8, 2019
1 parent f5b4fb6 commit 3f6c304
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/fff_test_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ int main()
RUN_TEST(FFFTestSuite, can_capture_upto_20_arguments_correctly);
RUN_TEST(FFFTestSuite, value_func_can_capture_upto_20_arguments_correctly);

RUN_TEST(FFFTestSuite, reset_list_index_is_incremented_upon_call_of_fake);
RUN_TEST(FFFTestSuite, reset_list_index_is_reset_upon_call_of_FFF_RESET_CALLED_FAKES);
RUN_TEST(FFFTestSuite, called_fakes_are_reset_upon_call_of_FFF_RESET_CALLED_FAKES);
RUN_TEST(FFFTestSuite, reset_list_stores_unique_entries_only);

printf("\n-------------\n");
printf("Complete\n");
printf("-------------\n\n");
Expand Down
37 changes: 37 additions & 0 deletions test/test_cases.include
Original file line number Diff line number Diff line change
Expand Up @@ -535,3 +535,40 @@ TEST_F(FFFTestSuite, value_func_can_capture_upto_20_arguments_correctly)
ASSERT_EQ(19, valuefunc20_fake.arg19_val);
}

TEST_F(FFFTestSuite, reset_list_index_is_incremented_upon_call_of_fake)
{
ASSERT_EQ(0U, voidfunc1_fake.call_count);
ASSERT_EQ(0U, fff.reset_list_idx);
voidfunc1(0);
ASSERT_EQ(1U, voidfunc1_fake.call_count);
ASSERT_EQ(1U, fff.reset_list_idx);
}

TEST_F(FFFTestSuite, reset_list_index_is_reset_upon_call_of_FFF_RESET_CALLED_FAKES)
{
voidfunc1(0);
voidfunc2('a', 'b');
voidfunc3var("hello", 0);
FFF_RESET_CALLED_FAKES();
ASSERT_EQ(0U, fff.reset_list_idx);
}

TEST_F(FFFTestSuite, called_fakes_are_reset_upon_call_of_FFF_RESET_CALLED_FAKES)
{
voidfunc1(0);
voidfunc2('a', 'b');
voidfunc3var("hello", 0);
FFF_RESET_CALLED_FAKES();
ASSERT_EQ(0U, voidfunc1_fake.call_count);
ASSERT_EQ(0U, voidfunc2_fake.call_count);
ASSERT_EQ(0U, voidfunc3var_fake.call_count);
}

TEST_F(FFFTestSuite, reset_list_stores_unique_entries_only)
{
voidfunc1(0);
voidfunc1(0);
voidfunc1(0);
ASSERT_EQ(1U, fff.reset_list_idx);
ASSERT_EQ(fff.reset_list[0], (fff_reset_function_t)voidfunc1_reset);
}

0 comments on commit 3f6c304

Please sign in to comment.