diff options
author | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-02-12 01:34:27 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-02-12 01:34:27 +0000 |
commit | ce198ff8997775d63b802615ee0cea5886ab82ab (patch) | |
tree | 36b65dc5a69bf2df77d7102657755b3ec2e7dfd8 /src/gmock-internal-utils.cc | |
parent | 2f0849fef4883a9cb9e785ae0f90a6d0d00d2959 (diff) | |
download | googletest-ce198ff8997775d63b802615ee0cea5886ab82ab.tar.gz googletest-ce198ff8997775d63b802615ee0cea5886ab82ab.tar.bz2 googletest-ce198ff8997775d63b802615ee0cea5886ab82ab.zip |
Implements the MATCHER* macros.
Diffstat (limited to 'src/gmock-internal-utils.cc')
-rw-r--r-- | src/gmock-internal-utils.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/gmock-internal-utils.cc b/src/gmock-internal-utils.cc index 58bc64e4..735abce5 100644 --- a/src/gmock-internal-utils.cc +++ b/src/gmock-internal-utils.cc @@ -37,6 +37,7 @@ #include <gmock/internal/gmock-internal-utils.h> +#include <ctype.h> #include <ostream> // NOLINT #include <string> #include <gmock/gmock.h> @@ -46,6 +47,29 @@ namespace testing { namespace internal { +// Converts an identifier name to a space-separated list of lower-case +// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is +// treated as one word. For example, both "FooBar123" and +// "foo_bar_123" are converted to "foo bar 123". +string ConvertIdentifierNameToWords(const char* id_name) { + string result; + char prev_char = '\0'; + for (const char* p = id_name; *p != '\0'; prev_char = *(p++)) { + // We don't care about the current locale as the input is + // guaranteed to be a valid C++ identifier name. + const bool starts_new_word = isupper(*p) || + (!isalpha(prev_char) && islower(*p)) || + (!isdigit(prev_char) && isdigit(*p)); + + if (isalnum(*p)) { + if (starts_new_word && result != "") + result += ' '; + result += tolower(*p); + } + } + return result; +} + // This class reports Google Mock failures as Google Test failures. A // user can define another class in a similar fashion if he intends to // use Google Mock with a testing framework other than Google Test. |