-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgtest_helpers.cpp
85 lines (70 loc) · 2.55 KB
/
gtest_helpers.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/******************************************************************************/
/*!
* @file gtest_helpers.cpp
* @brief
*
* @author Cathal Harte <cathal.harte@protonmail.com>
*/
/*******************************************************************************
* Includes
******************************************************************************/
#include <gtest/gtest.h>
#include <fff.h>
/*******************************************************************************
* Definitions
*******************************************************************************/
/*******************************************************************************
* Types
*******************************************************************************/
/*******************************************************************************
* Internal function prototypes
*******************************************************************************/
/*******************************************************************************
* Classes
*******************************************************************************/
/*******************************************************************************
* Functions
*******************************************************************************/
namespace gtest_helpers
{
void in_call_history(fff_globals_t * fff, void * function)
{
bool in_call_history = false;
for(int i = 0; i < fff->call_history_idx; i++)
{
if(fff->call_history[i] == function)
{
in_call_history = true;
}
}
EXPECT_TRUE(in_call_history);
}
void is_called_after(fff_globals_t * fff, void * function, void ** prerequisite_functions, int32_t num_prerequisite_functions)
{
int32_t call_history_loc;
bool is_called = false;
bool is_called_after = true;
int curr_history_idx = 0;
for(; curr_history_idx < fff->call_history_idx; curr_history_idx++)
{
if(fff->call_history[curr_history_idx] == function)
{
call_history_loc = curr_history_idx;
is_called = true;
break;
}
}
EXPECT_TRUE(is_called);
for(; curr_history_idx < fff->call_history_idx; curr_history_idx++)
{
for(int function_addr = 0; function_addr < num_prerequisite_functions; function_addr++)
{
if(fff->call_history[curr_history_idx] == prerequisite_functions[function_addr])
{
is_called_after = false;
}
}
}
EXPECT_TRUE(is_called_after) << "this the index " << curr_history_idx << std::endl;
}
}