| OLD | NEW |
| (Empty) |
| 1 // Copyright 2008 Google Inc. | |
| 2 // All Rights Reserved. | |
| 3 // | |
| 4 // Redistribution and use in source and binary forms, with or without | |
| 5 // modification, are permitted provided that the following conditions are | |
| 6 // met: | |
| 7 // | |
| 8 // * Redistributions of source code must retain the above copyright | |
| 9 // notice, this list of conditions and the following disclaimer. | |
| 10 // * Redistributions in binary form must reproduce the above | |
| 11 // copyright notice, this list of conditions and the following disclaimer | |
| 12 // in the documentation and/or other materials provided with the | |
| 13 // distribution. | |
| 14 // * Neither the name of Google Inc. nor the names of its | |
| 15 // contributors may be used to endorse or promote products derived from | |
| 16 // this software without specific prior written permission. | |
| 17 // | |
| 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 // | |
| 30 // Author: wan@google.com (Zhanyong Wan) | |
| 31 | |
| 32 #include <gtest/gtest-typed-test.h> | |
| 33 #include <gtest/gtest.h> | |
| 34 | |
| 35 namespace testing { | |
| 36 namespace internal { | |
| 37 | |
| 38 #if GTEST_HAS_TYPED_TEST_P | |
| 39 | |
| 40 // Verifies that registered_tests match the test names in | |
| 41 // defined_test_names_; returns registered_tests if successful, or | |
| 42 // aborts the program otherwise. | |
| 43 const char* TypedTestCasePState::VerifyRegisteredTestNames( | |
| 44 const char* file, int line, const char* registered_tests) { | |
| 45 typedef ::std::set<const char*>::const_iterator DefinedTestIter; | |
| 46 registered_ = true; | |
| 47 | |
| 48 Message errors; | |
| 49 ::std::set<String> tests; | |
| 50 for (const char* names = registered_tests; names != NULL; | |
| 51 names = SkipComma(names)) { | |
| 52 const String name = GetPrefixUntilComma(names); | |
| 53 if (tests.count(name) != 0) { | |
| 54 errors << "Test " << name << " is listed more than once.\n"; | |
| 55 continue; | |
| 56 } | |
| 57 | |
| 58 bool found = false; | |
| 59 for (DefinedTestIter it = defined_test_names_.begin(); | |
| 60 it != defined_test_names_.end(); | |
| 61 ++it) { | |
| 62 if (name == *it) { | |
| 63 found = true; | |
| 64 break; | |
| 65 } | |
| 66 } | |
| 67 | |
| 68 if (found) { | |
| 69 tests.insert(name); | |
| 70 } else { | |
| 71 errors << "No test named " << name | |
| 72 << " can be found in this test case.\n"; | |
| 73 } | |
| 74 } | |
| 75 | |
| 76 for (DefinedTestIter it = defined_test_names_.begin(); | |
| 77 it != defined_test_names_.end(); | |
| 78 ++it) { | |
| 79 if (tests.count(*it) == 0) { | |
| 80 errors << "You forgot to list test " << *it << ".\n"; | |
| 81 } | |
| 82 } | |
| 83 | |
| 84 const String& errors_str = errors.GetString(); | |
| 85 if (errors_str != "") { | |
| 86 fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(), | |
| 87 errors_str.c_str()); | |
| 88 fflush(stderr); | |
| 89 posix::Abort(); | |
| 90 } | |
| 91 | |
| 92 return registered_tests; | |
| 93 } | |
| 94 | |
| 95 #endif // GTEST_HAS_TYPED_TEST_P | |
| 96 | |
| 97 } // namespace internal | |
| 98 } // namespace testing | |
| OLD | NEW |