forked from 3rd-party/fff
Merge branch 'argument_history'
This commit is contained in:
@@ -9,6 +9,7 @@ void setup();
|
||||
#define TEST_F(SUITE, NAME) void NAME()
|
||||
#define RUN_TEST(SUITE, TESTNAME) printf(" Running %s.%s: \n", #SUITE, #TESTNAME); setup(); TESTNAME(); printf(" SUCCESS\n");
|
||||
#define ASSERT_EQ(A, B) assert((A) == (B))
|
||||
#define ASSERT(A) assert((A))
|
||||
|
||||
FAKE_VOID_FUNC1(voidfunc1, int);
|
||||
FAKE_VOID_FUNC2(voidfunc2, char, char);
|
||||
@@ -85,8 +86,6 @@ TEST_F(FFFTestSuite, when_void_func_with_2_char_args_called_and_reset_then_captu
|
||||
ASSERT_EQ(voidfunc2_arg1_val, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Argument history
|
||||
TEST_F(FFFTestSuite, when_fake_func_created_default_history_is_ten_calls)
|
||||
{
|
||||
@@ -117,9 +116,9 @@ TEST_F(FFFTestSuite, argument_history_is_reset_when_RESET_FAKE_called)
|
||||
TEST_F(FFFTestSuite, when_fake_func_called_max_times_then_no_argument_histories_dropped)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 10; i++)
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
voidfunc2('1'+i, '2'+i);
|
||||
voidfunc2('1' + i, '2' + i);
|
||||
}
|
||||
ASSERT_EQ(0u, voidfunc2_arg_histories_dropped);
|
||||
}
|
||||
@@ -127,16 +126,16 @@ TEST_F(FFFTestSuite, when_fake_func_called_max_times_then_no_argument_histories_
|
||||
TEST_F(FFFTestSuite, when_fake_func_called_max_times_plus_one_then_one_argument_history_dropped)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 10; i++)
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
voidfunc2('1'+i, '2'+i);
|
||||
voidfunc2('1' + i, '2' + i);
|
||||
}
|
||||
voidfunc2('1', '2');
|
||||
ASSERT_EQ(1u, voidfunc2_arg_histories_dropped);
|
||||
// Or in other words...
|
||||
ASSERT(voidfunc2_arg_history_len < voidfunc2_call_count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Return values
|
||||
TEST_F(FFFTestSuite, value_func_will_return_zero_by_default)
|
||||
{
|
||||
@@ -156,7 +155,6 @@ TEST_F(FFFTestSuite, value_func_will_return_zero_after_reset)
|
||||
ASSERT_EQ(0l, longfunc0());
|
||||
}
|
||||
|
||||
|
||||
TEST_F(FFFTestSuite, register_call_macro_registers_one_call)
|
||||
{
|
||||
REGISTER_CALL(longfunc0);
|
||||
@@ -184,13 +182,13 @@ TEST_F(FFFTestSuite, reset_call_history_resets_call_history)
|
||||
|
||||
TEST_F(FFFTestSuite, call_history_will_not_write_past_array_bounds)
|
||||
{
|
||||
for(unsigned int i = 0; i<MAX_CALL_HISTORY+1; i++){
|
||||
for (unsigned int i = 0; i < MAX_CALL_HISTORY + 1; i++)
|
||||
{
|
||||
REGISTER_CALL(longfunc0);
|
||||
}
|
||||
ASSERT_EQ(MAX_CALL_HISTORY, call_history_idx);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(FFFTestSuite, calling_fake_registers_one_call)
|
||||
{
|
||||
longfunc0();
|
||||
@@ -198,8 +196,6 @@ TEST_F(FFFTestSuite, calling_fake_registers_one_call)
|
||||
ASSERT_EQ(call_history[0], (void *)longfunc0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
setbuf(stdout, NULL);
|
||||
|
||||
@@ -12,7 +12,7 @@ FAKE_VOID_FUNC1(voidfunc1, int);
|
||||
FAKE_VOID_FUNC2(voidfunc2, char, char);
|
||||
FAKE_VALUE_FUNC0(long, longfunc0);
|
||||
|
||||
class FFFTestSuite : public testing::Test
|
||||
class FFFTestSuite: public testing::Test
|
||||
{
|
||||
public:
|
||||
void SetUp()
|
||||
@@ -86,8 +86,6 @@ TEST_F(FFFTestSuite, when_void_func_with_2_char_args_called_and_reset_then_captu
|
||||
ASSERT_EQ(voidfunc2_arg1_val, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Argument history
|
||||
TEST_F(FFFTestSuite, when_fake_func_created_default_history_is_ten_calls)
|
||||
{
|
||||
@@ -118,9 +116,9 @@ TEST_F(FFFTestSuite, argument_history_is_reset_when_RESET_FAKE_called)
|
||||
TEST_F(FFFTestSuite, when_fake_func_called_max_times_then_no_argument_histories_dropped)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 10; i++)
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
voidfunc2('1'+i, '2'+i);
|
||||
voidfunc2('1' + i, '2' + i);
|
||||
}
|
||||
ASSERT_EQ(0u, voidfunc2_arg_histories_dropped);
|
||||
}
|
||||
@@ -128,16 +126,16 @@ TEST_F(FFFTestSuite, when_fake_func_called_max_times_then_no_argument_histories_
|
||||
TEST_F(FFFTestSuite, when_fake_func_called_max_times_plus_one_then_one_argument_history_dropped)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 10; i++)
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
voidfunc2('1'+i, '2'+i);
|
||||
voidfunc2('1' + i, '2' + i);
|
||||
}
|
||||
voidfunc2('1', '2');
|
||||
ASSERT_EQ(1u, voidfunc2_arg_histories_dropped);
|
||||
// or in other words..
|
||||
ASSERT_GT(voidfunc2_call_count, voidfunc2_arg_history_len);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Return values
|
||||
TEST_F(FFFTestSuite, value_func_will_return_zero_by_default)
|
||||
{
|
||||
@@ -157,7 +155,6 @@ TEST_F(FFFTestSuite, value_func_will_return_zero_after_reset)
|
||||
ASSERT_EQ(0l, longfunc0());
|
||||
}
|
||||
|
||||
|
||||
TEST_F(FFFTestSuite, register_call_macro_registers_one_call)
|
||||
{
|
||||
REGISTER_CALL(longfunc0);
|
||||
@@ -185,13 +182,13 @@ TEST_F(FFFTestSuite, reset_call_history_resets_call_history)
|
||||
|
||||
TEST_F(FFFTestSuite, call_history_will_not_write_past_array_bounds)
|
||||
{
|
||||
for(unsigned int i = 0; i<MAX_CALL_HISTORY+1; i++){
|
||||
for (unsigned int i = 0; i < MAX_CALL_HISTORY + 1; i++)
|
||||
{
|
||||
REGISTER_CALL(longfunc0);
|
||||
}
|
||||
ASSERT_EQ(MAX_CALL_HISTORY, call_history_idx);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(FFFTestSuite, calling_fake_registers_one_call)
|
||||
{
|
||||
longfunc0();
|
||||
|
||||
Reference in New Issue
Block a user