Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
gmock_test.cc File Reference
#include "gmock/gmock.h"
#include <string>
#include "gtest/gtest.h"
#include "gtest/internal/custom/gtest.h"
Include dependency graph for gmock_test.cc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename Char , int M, int N>
void TestInitGoogleMock (const Char *(&argv)[M], const Char *(&new_argv)[N], const ::std::string &expected_gmock_verbose)
 
 TEST (InitGoogleMockTest, ParsesInvalidCommandLine)
 
 TEST (InitGoogleMockTest, ParsesEmptyCommandLine)
 
 TEST (InitGoogleMockTest, ParsesSingleFlag)
 
 TEST (InitGoogleMockTest, ParsesMultipleFlags)
 
 TEST (InitGoogleMockTest, ParsesUnrecognizedFlag)
 
 TEST (InitGoogleMockTest, ParsesGoogleMockFlagAndUnrecognizedFlag)
 
 TEST (WideInitGoogleMockTest, ParsesInvalidCommandLine)
 
 TEST (WideInitGoogleMockTest, ParsesEmptyCommandLine)
 
 TEST (WideInitGoogleMockTest, ParsesSingleFlag)
 
 TEST (WideInitGoogleMockTest, ParsesMultipleFlags)
 
 TEST (WideInitGoogleMockTest, ParsesUnrecognizedFlag)
 
 TEST (WideInitGoogleMockTest, ParsesGoogleMockFlagAndUnrecognizedFlag)
 
 TEST (FlagTest, IsAccessibleInCode)
 

Function Documentation

◆ TEST() [1/13]

TEST ( FlagTest ,
IsAccessibleInCode  )

Definition at line 258 of file gmock_test.cc.

258 {
259 bool dummy = testing::GMOCK_FLAG(catch_leaked_mocks) &&
260 testing::GMOCK_FLAG(verbose) == "";
261 (void)dummy; // Avoids the "unused local variable" warning.
262}
constexpr enabler dummy
An instance to use in EnableIf.
Definition CLI11.hpp:856

◆ TEST() [2/13]

TEST ( InitGoogleMockTest ,
ParsesEmptyCommandLine  )

Definition at line 79 of file gmock_test.cc.

79 {
80 const char* argv[] = {
81 "foo.exe",
82 NULL
83 };
84
85 const char* new_argv[] = {
86 "foo.exe",
87 NULL
88 };
89
90 TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose));
91}
#define GMOCK_FLAG(name)
Definition gmock-port.h:66
void TestInitGoogleMock(const Char *(&argv)[M], const Char *(&new_argv)[N], const ::std::string &expected_gmock_verbose)
Definition gmock_test.cc:51
char ** argv
Here is the call graph for this function:

◆ TEST() [3/13]

TEST ( InitGoogleMockTest ,
ParsesGoogleMockFlagAndUnrecognizedFlag  )

Definition at line 144 of file gmock_test.cc.

144 {
145 const char* argv[] = {
146 "foo.exe",
147 "--non_gmock_flag=blah",
148 "--gmock_verbose=error",
149 NULL
150 };
151
152 const char* new_argv[] = {
153 "foo.exe",
154 "--non_gmock_flag=blah",
155 NULL
156 };
157
158 TestInitGoogleMock(argv, new_argv, "error");
159}
Here is the call graph for this function:

◆ TEST() [4/13]

TEST ( InitGoogleMockTest ,
ParsesInvalidCommandLine  )

Definition at line 67 of file gmock_test.cc.

67 {
68 const char* argv[] = {
69 NULL
70 };
71
72 const char* new_argv[] = {
73 NULL
74 };
75
76 TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose));
77}
Here is the call graph for this function:

◆ TEST() [5/13]

TEST ( InitGoogleMockTest ,
ParsesMultipleFlags  )

Definition at line 108 of file gmock_test.cc.

108 {
109 int old_default_behavior = GMOCK_FLAG(default_mock_behavior);
110 const wchar_t* argv[] = {
111 L"foo.exe",
112 L"--gmock_verbose=info",
113 L"--gmock_default_mock_behavior=2",
114 NULL
115 };
116
117 const wchar_t* new_argv[] = {
118 L"foo.exe",
119 NULL
120 };
121
122 TestInitGoogleMock(argv, new_argv, "info");
123 EXPECT_EQ(2, GMOCK_FLAG(default_mock_behavior));
124 EXPECT_NE(2, old_default_behavior);
125 GMOCK_FLAG(default_mock_behavior) = old_default_behavior;
126}
#define EXPECT_EQ(val1, val2)
Definition gtest.h:1954
#define EXPECT_NE(val1, val2)
Definition gtest.h:1958
Here is the call graph for this function:

◆ TEST() [6/13]

TEST ( InitGoogleMockTest ,
ParsesSingleFlag  )

Definition at line 93 of file gmock_test.cc.

93 {
94 const char* argv[] = {
95 "foo.exe",
96 "--gmock_verbose=info",
97 NULL
98 };
99
100 const char* new_argv[] = {
101 "foo.exe",
102 NULL
103 };
104
105 TestInitGoogleMock(argv, new_argv, "info");
106}
Here is the call graph for this function:

◆ TEST() [7/13]

TEST ( InitGoogleMockTest ,
ParsesUnrecognizedFlag  )

Definition at line 128 of file gmock_test.cc.

128 {
129 const char* argv[] = {
130 "foo.exe",
131 "--non_gmock_flag=blah",
132 NULL
133 };
134
135 const char* new_argv[] = {
136 "foo.exe",
137 "--non_gmock_flag=blah",
138 NULL
139 };
140
141 TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose));
142}
Here is the call graph for this function:

◆ TEST() [8/13]

TEST ( WideInitGoogleMockTest ,
ParsesEmptyCommandLine  )

Definition at line 173 of file gmock_test.cc.

173 {
174 const wchar_t* argv[] = {
175 L"foo.exe",
176 NULL
177 };
178
179 const wchar_t* new_argv[] = {
180 L"foo.exe",
181 NULL
182 };
183
184 TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose));
185}
Here is the call graph for this function:

◆ TEST() [9/13]

TEST ( WideInitGoogleMockTest ,
ParsesGoogleMockFlagAndUnrecognizedFlag  )

Definition at line 238 of file gmock_test.cc.

238 {
239 const wchar_t* argv[] = {
240 L"foo.exe",
241 L"--non_gmock_flag=blah",
242 L"--gmock_verbose=error",
243 NULL
244 };
245
246 const wchar_t* new_argv[] = {
247 L"foo.exe",
248 L"--non_gmock_flag=blah",
249 NULL
250 };
251
252 TestInitGoogleMock(argv, new_argv, "error");
253}
Here is the call graph for this function:

◆ TEST() [10/13]

TEST ( WideInitGoogleMockTest ,
ParsesInvalidCommandLine  )

Definition at line 161 of file gmock_test.cc.

161 {
162 const wchar_t* argv[] = {
163 NULL
164 };
165
166 const wchar_t* new_argv[] = {
167 NULL
168 };
169
170 TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose));
171}
Here is the call graph for this function:

◆ TEST() [11/13]

TEST ( WideInitGoogleMockTest ,
ParsesMultipleFlags  )

Definition at line 202 of file gmock_test.cc.

202 {
203 int old_default_behavior = GMOCK_FLAG(default_mock_behavior);
204 const wchar_t* argv[] = {
205 L"foo.exe",
206 L"--gmock_verbose=info",
207 L"--gmock_default_mock_behavior=2",
208 NULL
209 };
210
211 const wchar_t* new_argv[] = {
212 L"foo.exe",
213 NULL
214 };
215
216 TestInitGoogleMock(argv, new_argv, "info");
217 EXPECT_EQ(2, GMOCK_FLAG(default_mock_behavior));
218 EXPECT_NE(2, old_default_behavior);
219 GMOCK_FLAG(default_mock_behavior) = old_default_behavior;
220}
Here is the call graph for this function:

◆ TEST() [12/13]

TEST ( WideInitGoogleMockTest ,
ParsesSingleFlag  )

Definition at line 187 of file gmock_test.cc.

187 {
188 const wchar_t* argv[] = {
189 L"foo.exe",
190 L"--gmock_verbose=info",
191 NULL
192 };
193
194 const wchar_t* new_argv[] = {
195 L"foo.exe",
196 NULL
197 };
198
199 TestInitGoogleMock(argv, new_argv, "info");
200}
Here is the call graph for this function:

◆ TEST() [13/13]

TEST ( WideInitGoogleMockTest ,
ParsesUnrecognizedFlag  )

Definition at line 222 of file gmock_test.cc.

222 {
223 const wchar_t* argv[] = {
224 L"foo.exe",
225 L"--non_gmock_flag=blah",
226 NULL
227 };
228
229 const wchar_t* new_argv[] = {
230 L"foo.exe",
231 L"--non_gmock_flag=blah",
232 NULL
233 };
234
235 TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose));
236}
Here is the call graph for this function:

◆ TestInitGoogleMock()

template<typename Char , int M, int N>
void TestInitGoogleMock ( const Char *(&) argv[M],
const Char *(&) new_argv[N],
const ::std::string & expected_gmock_verbose )

Definition at line 51 of file gmock_test.cc.

52 {
53 const ::std::string old_verbose = GMOCK_FLAG(verbose);
54
55 int argc = M - 1;
56 InitGoogleMock(&argc, const_cast<Char**>(argv));
57 ASSERT_EQ(N - 1, argc) << "The new argv has wrong number of elements.";
58
59 for (int i = 0; i < N; i++) {
60 EXPECT_STREQ(new_argv[i], argv[i]);
61 }
62
63 EXPECT_EQ(expected_gmock_verbose, GMOCK_FLAG(verbose).c_str());
64 GMOCK_FLAG(verbose) = old_verbose; // Restores the gmock_verbose flag.
65}
#define ASSERT_EQ(val1, val2)
Definition gtest.h:1988
#define EXPECT_STREQ(s1, s2)
Definition gtest.h:2027
const int N
Definition quantize.cpp:54
Here is the caller graph for this function: