[MIPS GlobalISel] Select MSA vector generic and builtin add
[llvm-complete.git] / utils / unittest / googletest / src / gtest-typed-test.cc
blobdf1eef4754efeb6bc066239b1ccc3bfeeb896310
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.
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.
30 // Author: wan@google.com (Zhanyong Wan)
32 #include "gtest/gtest-typed-test.h"
33 #include "gtest/gtest.h"
35 namespace testing {
36 namespace internal {
38 #if GTEST_HAS_TYPED_TEST_P
40 // Skips to the first non-space char in str. Returns an empty string if str
41 // contains only whitespace characters.
42 static const char* SkipSpaces(const char* str) {
43 while (IsSpace(*str))
44 str++;
45 return str;
48 static std::vector<std::string> SplitIntoTestNames(const char* src) {
49 std::vector<std::string> name_vec;
50 src = SkipSpaces(src);
51 for (; src != NULL; src = SkipComma(src)) {
52 name_vec.push_back(StripTrailingSpaces(GetPrefixUntilComma(src)));
54 return name_vec;
57 // Verifies that registered_tests match the test names in
58 // registered_tests_; returns registered_tests if successful, or
59 // aborts the program otherwise.
60 const char* TypedTestCasePState::VerifyRegisteredTestNames(
61 const char* file, int line, const char* registered_tests) {
62 typedef RegisteredTestsMap::const_iterator RegisteredTestIter;
63 registered_ = true;
65 std::vector<std::string> name_vec = SplitIntoTestNames(registered_tests);
67 Message errors;
69 std::set<std::string> tests;
70 for (std::vector<std::string>::const_iterator name_it = name_vec.begin();
71 name_it != name_vec.end(); ++name_it) {
72 const std::string& name = *name_it;
73 if (tests.count(name) != 0) {
74 errors << "Test " << name << " is listed more than once.\n";
75 continue;
78 bool found = false;
79 for (RegisteredTestIter it = registered_tests_.begin();
80 it != registered_tests_.end();
81 ++it) {
82 if (name == it->first) {
83 found = true;
84 break;
88 if (found) {
89 tests.insert(name);
90 } else {
91 errors << "No test named " << name
92 << " can be found in this test case.\n";
96 for (RegisteredTestIter it = registered_tests_.begin();
97 it != registered_tests_.end();
98 ++it) {
99 if (tests.count(it->first) == 0) {
100 errors << "You forgot to list test " << it->first << ".\n";
104 const std::string& errors_str = errors.GetString();
105 if (errors_str != "") {
106 fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
107 errors_str.c_str());
108 fflush(stderr);
109 posix::Abort();
112 return registered_tests;
115 #endif // GTEST_HAS_TYPED_TEST_P
117 } // namespace internal
118 } // namespace testing