diff options
author | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-09-30 23:46:28 (GMT) |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-09-30 23:46:28 (GMT) |
commit | bd851333e89517762c91a3fef67cf25a6f1bd37a (patch) | |
tree | 9b23d718046f2e83236287dca1ad8a7c863a47e5 /include | |
parent | f8b268ee86ca74bba3276352f1e7de53d1336c3e (diff) | |
download | googletest-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')
-rw-r--r-- | include/gtest/gtest.h | 28 | ||||
-rw-r--r-- | include/gtest/internal/gtest-port.h | 2 |
2 files changed, 23 insertions, 7 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_; } diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h index ac460ee..ee97881 100644 --- a/include/gtest/internal/gtest-port.h +++ b/include/gtest/internal/gtest-port.h @@ -461,7 +461,7 @@ // pops up a dialog window that cannot be suppressed programmatically. #if GTEST_HAS_STD_STRING && \ (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN || \ - (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400)) + (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || GTEST_OS_WINDOWS_MINGW) #define GTEST_HAS_DEATH_TEST 1 #include <vector> // NOLINT #endif |