| 7421 | // instantiated to either char or wchar_t. |
| 7422 | template <typename CharType> |
| 7423 | void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) { |
| 7424 | for (int i = 1; i < *argc; i++) { |
| 7425 | const std::string arg_string = StreamableToString(argv[i]); |
| 7426 | const char* const arg = arg_string.c_str(); |
| 7427 | |
| 7428 | using internal::ParseBoolFlag; |
| 7429 | using internal::ParseInt32Flag; |
| 7430 | using internal::ParseStringFlag; |
| 7431 | |
| 7432 | bool remove_flag = false; |
| 7433 | if (ParseGoogleTestFlag(arg)) { |
| 7434 | remove_flag = true; |
| 7435 | #if GTEST_USE_OWN_FLAGFILE_FLAG_ |
| 7436 | } else if (ParseStringFlag(arg, kFlagfileFlag, >EST_FLAG(flagfile))) { |
| 7437 | LoadFlagsFromFile(GTEST_FLAG(flagfile)); |
| 7438 | remove_flag = true; |
| 7439 | #endif // GTEST_USE_OWN_FLAGFILE_FLAG_ |
| 7440 | } else if (arg_string == "--help" || arg_string == "-h" || |
| 7441 | arg_string == "-?" || arg_string == "/?" || |
| 7442 | HasGoogleTestFlagPrefix(arg)) { |
| 7443 | // Both help flag and unrecognized Google Test flags (excluding |
| 7444 | // internal ones) trigger help display. |
| 7445 | g_help_flag = true; |
| 7446 | } |
| 7447 | |
| 7448 | if (remove_flag) { |
| 7449 | // Shift the remainder of the argv list left by one. Note |
| 7450 | // that argv has (*argc + 1) elements, the last one always being |
| 7451 | // NULL. The following loop moves the trailing NULL element as |
| 7452 | // well. |
| 7453 | for (int j = i; j != *argc; j++) { |
| 7454 | argv[j] = argv[j + 1]; |
| 7455 | } |
| 7456 | |
| 7457 | // Decrements the argument count. |
| 7458 | (*argc)--; |
| 7459 | |
| 7460 | // We also need to decrement the iterator as we just removed |
| 7461 | // an element. |
| 7462 | i--; |
| 7463 | } |
| 7464 | } |
| 7465 | |
| 7466 | if (g_help_flag) { |
| 7467 | // We print the help here instead of in RUN_ALL_TESTS(), as the |
| 7468 | // latter may not be called at all if the user is using Google |
| 7469 | // Test with another testing framework. |
| 7470 | PrintColorEncoded(kColorEncodedHelpMessage); |
| 7471 | } |
| 7472 | } |
| 7473 | |
| 7474 | // Parses the command line for Google Test flags, without initializing |
| 7475 | // other parts of Google Test. |
no test coverage detected