summaryrefslogtreecommitdiffstats
path: root/include/gtest/gtest.h
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-09-30 23:46:28 (GMT)
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-09-30 23:46:28 (GMT)
commitbd851333e89517762c91a3fef67cf25a6f1bd37a (patch)
tree9b23d718046f2e83236287dca1ad8a7c863a47e5 /include/gtest/gtest.h
parentf8b268ee86ca74bba3276352f1e7de53d1336c3e (diff)
downloadgoogletest-bd851333e89517762c91a3fef67cf25a6f1bd37a.zip
googletest-bd851333e89517762c91a3fef67cf25a6f1bd37a.tar.gz
googletest-bd851333e89517762c91a3fef67cf25a6f1bd37a.tar.bz2
Implements test shuffling (by Zhanyong Wan, based on Josh Kelley's original patch).
Enables death tests on minGW (by Vlad Losev).
Diffstat (limited to 'include/gtest/gtest.h')
-rw-r--r--include/gtest/gtest.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/include/gtest/gtest.h b/include/gtest/gtest.h
index 6fc5ac5..9be15fb 100644
--- a/include/gtest/gtest.h
+++ b/include/gtest/gtest.h
@@ -127,7 +127,7 @@ GTEST_DECLARE_int32_(repeat);
// stack frames in failure stack traces.
GTEST_DECLARE_bool_(show_internal_stack_frames);
-// When this flag is specified, tests' order is randomized on every run.
+// When this flag is specified, tests' order is randomized on every iteration.
GTEST_DECLARE_bool_(shuffle);
// This flag specifies the maximum number of stack frames to be
@@ -675,6 +675,10 @@ class TestCase {
return *test_info_list_;
}
+ // Returns the i-th test among all the tests. i can range from 0 to
+ // total_test_count() - 1. If i is not in that range, returns NULL.
+ TestInfo* GetMutableTestInfo(int i);
+
// Sets the should_run member.
void set_should_run(bool should) { should_run_ = should; }
@@ -693,9 +697,6 @@ class TestCase {
// Runs every test in this TestCase.
void Run();
- // Runs every test in the given TestCase.
- static void RunTestCase(TestCase * test_case) { test_case->Run(); }
-
// Returns true iff test passed.
static bool TestPassed(const TestInfo * test_info);
@@ -708,12 +709,23 @@ class TestCase {
// Returns true if the given test should run.
static bool ShouldRunTest(const TestInfo *test_info);
+ // Shuffles the tests in this test case.
+ void ShuffleTests(internal::Random* random);
+
+ // Restores the test order to before the first shuffle.
+ void UnshuffleTests();
+
// Name of the test case.
internal::String name_;
// Comment on the test case.
internal::String comment_;
- // Vector of TestInfos.
- internal::Vector<TestInfo*>* test_info_list_;
+ // The vector of TestInfos in their original order. It owns the
+ // elements in the vector.
+ const internal::scoped_ptr<internal::Vector<TestInfo*> > test_info_list_;
+ // Provides a level of indirection for the test list to allow easy
+ // shuffling and restoring the test order. The i-th element in this
+ // vector is the index of the i-th test in the shuffled test list.
+ const internal::scoped_ptr<internal::Vector<int> > test_indices_;
// Pointer to the function that sets up the test case.
Test::SetUpTestCaseFunc set_up_tc_;
// Pointer to the function that tears down the test case.
@@ -1030,6 +1042,10 @@ class UnitTest {
// contains a property with the same key, the value will be updated.
void RecordPropertyForCurrentTest(const char* key, const char* value);
+ // Gets the i-th test case among all the test cases. i can range from 0 to
+ // total_test_case_count() - 1. If i is not in that range, returns NULL.
+ TestCase* GetMutableTestCase(int i);
+
// Accessors for the implementation object.
internal::UnitTestImpl* impl() { return impl_; }
const internal::UnitTestImpl* impl() const { return impl_; }