summaryrefslogtreecommitdiff
path: root/include/gtest/gtest.h
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-06-19 21:20:40 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-06-19 21:20:40 +0000
commit535de1065311cc5e95e84811dc05f513393fa940 (patch)
treeb22229f7fb18d6fbf3f41322727d1c53c75f39f0 /include/gtest/gtest.h
parentc427f5e8ab231012d7663a0ee408f1225bac971a (diff)
downloadgoogletest-535de1065311cc5e95e84811dc05f513393fa940.tar.gz
Moves TestResult from gtest-internal-inl.h to gtest.h to prepare for the even listener API work (by Vlad Losev); cleans up the scons script (by Zhanyong Wan).
git-svn-id: http://googletest.googlecode.com/svn/trunk@271 861a406c-534a-0410-8894-cb66d6ee9925
Diffstat (limited to 'include/gtest/gtest.h')
-rw-r--r--include/gtest/gtest.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/include/gtest/gtest.h b/include/gtest/gtest.h
index d15909b..1c504f8 100644
--- a/include/gtest/gtest.h
+++ b/include/gtest/gtest.h
@@ -383,6 +383,102 @@ class TestProperty {
String value_;
};
+// The result of a single Test. This includes a list of
+// TestPartResults, a list of TestProperties, a count of how many
+// death tests there are in the Test, and how much time it took to run
+// the Test.
+//
+// TestResult is not copyable.
+class TestResult {
+ public:
+ // Creates an empty TestResult.
+ TestResult();
+
+ // D'tor. Do not inherit from TestResult.
+ ~TestResult();
+
+ // Gets the list of TestPartResults.
+ const internal::List<TestPartResult>& test_part_results() const {
+ return *test_part_results_;
+ }
+
+ // Gets the list of TestProperties.
+ const internal::List<internal::TestProperty>& test_properties() const {
+ return *test_properties_;
+ }
+
+ // Gets the number of successful test parts.
+ int successful_part_count() const;
+
+ // Gets the number of failed test parts.
+ int failed_part_count() const;
+
+ // Gets the number of all test parts. This is the sum of the number
+ // of successful test parts and the number of failed test parts.
+ int total_part_count() const;
+
+ // Returns true iff the test passed (i.e. no test part failed).
+ bool Passed() const { return !Failed(); }
+
+ // Returns true iff the test failed.
+ bool Failed() const { return failed_part_count() > 0; }
+
+ // Returns true iff the test fatally failed.
+ bool HasFatalFailure() const;
+
+ // Returns true iff the test has a non-fatal failure.
+ bool HasNonfatalFailure() const;
+
+ // Returns the elapsed time, in milliseconds.
+ TimeInMillis elapsed_time() const { return elapsed_time_; }
+
+ // Sets the elapsed time.
+ void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; }
+
+ // Adds a test part result to the list.
+ void AddTestPartResult(const TestPartResult& test_part_result);
+
+ // Adds a test property to the list. The property is validated and may add
+ // a non-fatal failure if invalid (e.g., if it conflicts with reserved
+ // key names). If a property is already recorded for the same key, the
+ // value will be updated, rather than storing multiple values for the same
+ // key.
+ void RecordProperty(const internal::TestProperty& test_property);
+
+ // Adds a failure if the key is a reserved attribute of Google Test
+ // testcase tags. Returns true if the property is valid.
+ // TODO(russr): Validate attribute names are legal and human readable.
+ static bool ValidateTestProperty(const internal::TestProperty& test_property);
+
+ // Returns the death test count.
+ int death_test_count() const { return death_test_count_; }
+
+ // Increments the death test count, returning the new count.
+ int increment_death_test_count() { return ++death_test_count_; }
+
+ // Clears the test part results.
+ void ClearTestPartResults();
+
+ // Clears the object.
+ void Clear();
+ private:
+ // Protects mutable state of the property list and of owned properties, whose
+ // values may be updated.
+ internal::Mutex test_properites_mutex_;
+
+ // The list of TestPartResults
+ scoped_ptr<internal::List<TestPartResult> > test_part_results_;
+ // The list of TestProperties
+ scoped_ptr<internal::List<internal::TestProperty> > test_properties_;
+ // Running count of death tests.
+ int death_test_count_;
+ // The elapsed time, in milliseconds.
+ TimeInMillis elapsed_time_;
+
+ // We disallow copying TestResult.
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult);
+}; // class TestResult
+
} // namespace internal
// A TestInfo object stores the following information about a test: