OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/test/launcher/test_result.h" | 5 #include "base/test/launcher/test_result.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
11 namespace base { | 11 namespace base { |
12 | 12 |
| 13 TestResultPart::TestResultPart() = default; |
| 14 TestResultPart::~TestResultPart() = default; |
| 15 |
| 16 TestResultPart::TestResultPart(const TestResultPart& other) = default; |
| 17 TestResultPart::TestResultPart(TestResultPart&& other) = default; |
| 18 TestResultPart& TestResultPart::operator=(const TestResultPart& other) = |
| 19 default; |
| 20 TestResultPart& TestResultPart::operator=(TestResultPart&& other) = default; |
| 21 |
| 22 // static |
| 23 bool TestResultPart::TypeFromString(const std::string& str, Type* type) { |
| 24 if (str == "success") |
| 25 *type = kSuccess; |
| 26 else if (str == "failure") |
| 27 *type = kNonFatalFailure; |
| 28 else if (str == "fatal_failure") |
| 29 *type = kFatalFailure; |
| 30 else |
| 31 return false; |
| 32 return true; |
| 33 } |
| 34 |
| 35 std::string TestResultPart::TypeAsString() const { |
| 36 switch (type) { |
| 37 case kSuccess: |
| 38 return "success"; |
| 39 case kNonFatalFailure: |
| 40 return "failure"; |
| 41 case kFatalFailure: |
| 42 return "fatal_failure"; |
| 43 default: |
| 44 NOTREACHED(); |
| 45 } |
| 46 return "unknown"; |
| 47 } |
| 48 |
13 TestResult::TestResult() : status(TEST_UNKNOWN) { | 49 TestResult::TestResult() : status(TEST_UNKNOWN) { |
14 } | 50 } |
15 | 51 |
16 TestResult::~TestResult() { | 52 TestResult::~TestResult() { |
17 } | 53 } |
18 | 54 |
| 55 TestResult::TestResult(const TestResult& other) = default; |
| 56 TestResult::TestResult(TestResult&& other) = default; |
| 57 TestResult& TestResult::operator=(const TestResult& other) = default; |
| 58 TestResult& TestResult::operator=(TestResult&& other) = default; |
| 59 |
19 std::string TestResult::StatusAsString() const { | 60 std::string TestResult::StatusAsString() const { |
20 switch (status) { | 61 switch (status) { |
21 case TEST_UNKNOWN: | 62 case TEST_UNKNOWN: |
22 return "UNKNOWN"; | 63 return "UNKNOWN"; |
23 case TEST_SUCCESS: | 64 case TEST_SUCCESS: |
24 return "SUCCESS"; | 65 return "SUCCESS"; |
25 case TEST_FAILURE: | 66 case TEST_FAILURE: |
26 return "FAILURE"; | 67 return "FAILURE"; |
27 case TEST_FAILURE_ON_EXIT: | 68 case TEST_FAILURE_ON_EXIT: |
28 return "FAILURE_ON_EXIT"; | 69 return "FAILURE_ON_EXIT"; |
(...skipping 18 matching lines...) Expand all Loading... |
47 return full_name.substr(dot_pos + 1); | 88 return full_name.substr(dot_pos + 1); |
48 } | 89 } |
49 | 90 |
50 std::string TestResult::GetTestCaseName() const { | 91 std::string TestResult::GetTestCaseName() const { |
51 size_t dot_pos = full_name.find('.'); | 92 size_t dot_pos = full_name.find('.'); |
52 CHECK_NE(dot_pos, std::string::npos); | 93 CHECK_NE(dot_pos, std::string::npos); |
53 return full_name.substr(0, dot_pos); | 94 return full_name.substr(0, dot_pos); |
54 } | 95 } |
55 | 96 |
56 } // namespace base | 97 } // namespace base |
OLD | NEW |