diff options
author | vladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925> | 2010-02-03 02:27:02 (GMT) |
---|---|---|
committer | vladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925> | 2010-02-03 02:27:02 (GMT) |
commit | cfcbc298cd91806e0e3417e03fce42bc4f1fa150 (patch) | |
tree | af456a0d47524f6bb5cbb49d160e0aaf60110daf /src | |
parent | 8d373310561a8d68d2a22ca7c6613deff5fa6e05 (diff) | |
download | googletest-cfcbc298cd91806e0e3417e03fce42bc4f1fa150.zip googletest-cfcbc298cd91806e0e3417e03fce42bc4f1fa150.tar.gz googletest-cfcbc298cd91806e0e3417e03fce42bc4f1fa150.tar.bz2 |
Adds Solaris support (by Hady Zalek)
Diffstat (limited to 'src')
-rw-r--r-- | src/gtest-filepath.cc | 3 | ||||
-rw-r--r-- | src/gtest-port.cc | 17 | ||||
-rw-r--r-- | src/gtest-typed-test.cc | 12 |
3 files changed, 26 insertions, 6 deletions
diff --git a/src/gtest-filepath.cc b/src/gtest-filepath.cc index 27a3342..c1ef918 100644 --- a/src/gtest-filepath.cc +++ b/src/gtest-filepath.cc @@ -342,9 +342,10 @@ FilePath FilePath::RemoveTrailingPathSeparator() const { : *this; } -// Normalize removes any redundant separators that might be in the pathname. +// Removes any redundant separators that might be in the pathname. // For example, "bar///foo" becomes "bar/foo". Does not eliminate other // redundancies that might be in a pathname involving "." or "..". +// TODO(wan@google.com): handle Windows network shares (e.g. \\server\share). void FilePath::Normalize() { if (pathname_.c_str() == NULL) { pathname_ = ""; diff --git a/src/gtest-port.cc b/src/gtest-port.cc index 957595a..7d89e26 100644 --- a/src/gtest-port.cc +++ b/src/gtest-port.cc @@ -111,8 +111,14 @@ size_t GetThreadCount() { // Implements RE. Currently only needed for death tests. RE::~RE() { - regfree(&partial_regex_); - regfree(&full_regex_); + if (is_valid_) { + // regfree'ing an invalid regex might crash because the content + // of the regex is undefined. Since the regex's are essentially + // the same, one cannot be valid (or invalid) without the other + // being so too. + regfree(&partial_regex_); + regfree(&full_regex_); + } free(const_cast<char*>(pattern_)); } @@ -152,9 +158,10 @@ void RE::Init(const char* regex) { // Some implementation of POSIX regex (e.g. on at least some // versions of Cygwin) doesn't accept the empty string as a valid // regex. We change it to an equivalent form "()" to be safe. - const char* const partial_regex = (*regex == '\0') ? "()" : regex; - is_valid_ = (regcomp(&partial_regex_, partial_regex, REG_EXTENDED) == 0) - && is_valid_; + if (is_valid_) { + const char* const partial_regex = (*regex == '\0') ? "()" : regex; + is_valid_ = regcomp(&partial_regex_, partial_regex, REG_EXTENDED) == 0; + } EXPECT_TRUE(is_valid_) << "Regular expression \"" << regex << "\" is not a valid POSIX Extended regular expression."; diff --git a/src/gtest-typed-test.cc b/src/gtest-typed-test.cc index 4a0f657..3cc4b5d 100644 --- a/src/gtest-typed-test.cc +++ b/src/gtest-typed-test.cc @@ -37,6 +37,14 @@ namespace internal { #if GTEST_HAS_TYPED_TEST_P +// Skips to the first non-space char in str. Returns an empty string if str +// contains only whitespace characters. +static const char* SkipSpaces(const char* str) { + while (isspace(*str)) + str++; + return str; +} + // Verifies that registered_tests match the test names in // defined_test_names_; returns registered_tests if successful, or // aborts the program otherwise. @@ -45,6 +53,10 @@ const char* TypedTestCasePState::VerifyRegisteredTestNames( typedef ::std::set<const char*>::const_iterator DefinedTestIter; registered_ = true; + // Skip initial whitespace in registered_tests since some + // preprocessors prefix stringizied literals with whitespace. + registered_tests = SkipSpaces(registered_tests); + Message errors; ::std::set<String> tests; for (const char* names = registered_tests; names != NULL; |