42#if !defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
44using testing::GMOCK_FLAG(default_mock_behavior);
45using testing::GMOCK_FLAG(
verbose);
50template <
typename Char,
int M,
int N>
52 const ::std::string& expected_gmock_verbose) {
53 const ::std::string old_verbose =
GMOCK_FLAG(verbose);
56 InitGoogleMock(&argc,
const_cast<Char**
>(
argv));
57 ASSERT_EQ(
N - 1, argc) <<
"The new argv has wrong number of elements.";
59 for (
int i = 0; i <
N; i++) {
67TEST(InitGoogleMockTest, ParsesInvalidCommandLine) {
68 const char*
argv[] = {
72 const char* new_argv[] = {
79TEST(InitGoogleMockTest, ParsesEmptyCommandLine) {
80 const char*
argv[] = {
85 const char* new_argv[] = {
93TEST(InitGoogleMockTest, ParsesSingleFlag) {
94 const char*
argv[] = {
96 "--gmock_verbose=info",
100 const char* new_argv[] = {
108TEST(InitGoogleMockTest, ParsesMultipleFlags) {
109 int old_default_behavior =
GMOCK_FLAG(default_mock_behavior);
110 const wchar_t*
argv[] = {
112 L
"--gmock_verbose=info",
113 L
"--gmock_default_mock_behavior=2",
117 const wchar_t* new_argv[] = {
125 GMOCK_FLAG(default_mock_behavior) = old_default_behavior;
128TEST(InitGoogleMockTest, ParsesUnrecognizedFlag) {
129 const char*
argv[] = {
131 "--non_gmock_flag=blah",
135 const char* new_argv[] = {
137 "--non_gmock_flag=blah",
144TEST(InitGoogleMockTest, ParsesGoogleMockFlagAndUnrecognizedFlag) {
145 const char*
argv[] = {
147 "--non_gmock_flag=blah",
148 "--gmock_verbose=error",
152 const char* new_argv[] = {
154 "--non_gmock_flag=blah",
161TEST(WideInitGoogleMockTest, ParsesInvalidCommandLine) {
162 const wchar_t*
argv[] = {
166 const wchar_t* new_argv[] = {
173TEST(WideInitGoogleMockTest, ParsesEmptyCommandLine) {
174 const wchar_t*
argv[] = {
179 const wchar_t* new_argv[] = {
187TEST(WideInitGoogleMockTest, ParsesSingleFlag) {
188 const wchar_t*
argv[] = {
190 L
"--gmock_verbose=info",
194 const wchar_t* new_argv[] = {
202TEST(WideInitGoogleMockTest, ParsesMultipleFlags) {
203 int old_default_behavior =
GMOCK_FLAG(default_mock_behavior);
204 const wchar_t*
argv[] = {
206 L
"--gmock_verbose=info",
207 L
"--gmock_default_mock_behavior=2",
211 const wchar_t* new_argv[] = {
219 GMOCK_FLAG(default_mock_behavior) = old_default_behavior;
222TEST(WideInitGoogleMockTest, ParsesUnrecognizedFlag) {
223 const wchar_t*
argv[] = {
225 L
"--non_gmock_flag=blah",
229 const wchar_t* new_argv[] = {
231 L
"--non_gmock_flag=blah",
238TEST(WideInitGoogleMockTest, ParsesGoogleMockFlagAndUnrecognizedFlag) {
239 const wchar_t*
argv[] = {
241 L
"--non_gmock_flag=blah",
242 L
"--gmock_verbose=error",
246 const wchar_t* new_argv[] = {
248 L
"--non_gmock_flag=blah",
258TEST(FlagTest, IsAccessibleInCode) {
259 bool dummy = testing::GMOCK_FLAG(catch_leaked_mocks) &&
260 testing::GMOCK_FLAG(verbose) ==
"";
void TestInitGoogleMock(const Char *(&argv)[M], const Char *(&new_argv)[N], const ::std::string &expected_gmock_verbose)
#define ASSERT_EQ(val1, val2)
#define EXPECT_EQ(val1, val2)
#define EXPECT_NE(val1, val2)
#define EXPECT_STREQ(s1, s2)
#define TEST(test_case_name, test_name)
GTEST_API_ void InitGoogleMock(int *argc, char **argv)