| 6552 | // instantiated to either char or wchar_t. |
| 6553 | template <typename CharType> |
| 6554 | void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) { |
| 6555 | for (int i = 1; i < *argc; i++) { |
| 6556 | const std::string arg_string = StreamableToString(argv[i]); |
| 6557 | const char* const arg = arg_string.c_str(); |
| 6558 | |
| 6559 | using internal::ParseBoolFlag; |
| 6560 | using internal::ParseInt32Flag; |
| 6561 | using internal::ParseStringFlag; |
| 6562 | |
| 6563 | bool remove_flag = false; |
| 6564 | if (ParseGoogleTestFlag(arg)) { |
| 6565 | remove_flag = true; |
| 6566 | #if GTEST_USE_OWN_FLAGFILE_FLAG_ |
| 6567 | } else if (ParseStringFlag(arg, kFlagfileFlag, >EST_FLAG(flagfile))) { |
| 6568 | LoadFlagsFromFile(GTEST_FLAG(flagfile)); |
| 6569 | remove_flag = true; |
| 6570 | #endif // GTEST_USE_OWN_FLAGFILE_FLAG_ |
| 6571 | } else if (arg_string == "--help" || arg_string == "-h" || |
| 6572 | arg_string == "-?" || arg_string == "/?" || |
| 6573 | HasGoogleTestFlagPrefix(arg)) { |
| 6574 | // Both help flag and unrecognized Google Test flags (excluding |
| 6575 | // internal ones) trigger help display. |
| 6576 | g_help_flag = true; |
| 6577 | } |
| 6578 | |
| 6579 | if (remove_flag) { |
| 6580 | // Shift the remainder of the argv list left by one. Note |
| 6581 | // that argv has (*argc + 1) elements, the last one always being |
| 6582 | // NULL. The following loop moves the trailing NULL element as |
| 6583 | // well. |
| 6584 | for (int j = i; j != *argc; j++) { |
| 6585 | argv[j] = argv[j + 1]; |
| 6586 | } |
| 6587 | |
| 6588 | // Decrements the argument count. |
| 6589 | (*argc)--; |
| 6590 | |
| 6591 | // We also need to decrement the iterator as we just removed |
| 6592 | // an element. |
| 6593 | i--; |
| 6594 | } |
| 6595 | } |
| 6596 | |
| 6597 | if (g_help_flag) { |
| 6598 | // We print the help here instead of in RUN_ALL_TESTS(), as the |
| 6599 | // latter may not be called at all if the user is using Google |
| 6600 | // Test with another testing framework. |
| 6601 | PrintColorEncoded(kColorEncodedHelpMessage); |
| 6602 | } |
| 6603 | } |
| 6604 | |
| 6605 | // Parses the command line for Google Test flags, without initializing |
| 6606 | // other parts of Google Test. |
no test coverage detected