diff options
author | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-06-24 23:02:50 (GMT) |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-06-24 23:02:50 (GMT) |
commit | e6095deec89dcf5237948b3460d84a137622f16c (patch) | |
tree | c0e3cbdc428e9461fa43b7f7d28636179ef0917a /include | |
parent | ef29ce3576240e51f289e49b2c4e156b414d6685 (diff) | |
download | googletest-e6095deec89dcf5237948b3460d84a137622f16c.zip googletest-e6095deec89dcf5237948b3460d84a137622f16c.tar.gz googletest-e6095deec89dcf5237948b3460d84a137622f16c.tar.bz2 |
Makes gtest's tuple implementation work with Symbian 5th edition by bypassing 2 compiler bugs (by Zhanyong Wan); refactors for the event listener API (by Vlad Losev).
Diffstat (limited to 'include')
-rw-r--r-- | include/gtest/gtest.h | 59 | ||||
-rw-r--r-- | include/gtest/internal/gtest-tuple.h | 79 | ||||
-rw-r--r-- | include/gtest/internal/gtest-tuple.h.pump | 25 |
3 files changed, 129 insertions, 34 deletions
diff --git a/include/gtest/gtest.h b/include/gtest/gtest.h index 66653d1..2b1c978 100644 --- a/include/gtest/gtest.h +++ b/include/gtest/gtest.h @@ -418,6 +418,9 @@ class TestResult { // of successful test parts and the number of failed test parts. int total_part_count() const; + // Returns the number of the test properties. + int test_property_count() const; + // Returns true iff the test passed (i.e. no test part failed). bool Passed() const { return !Failed(); } @@ -436,6 +439,15 @@ class TestResult { // Sets the elapsed time. void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; } + // Returns the i-th test part result among all the results. i can range + // from 0 to test_property_count() - 1. If i is not in that range, returns + // NULL. + const TestPartResult* GetTestPartResult(int i) const; + + // Returns the i-th test property. i can range from 0 to + // test_property_count() - 1. If i is not in that range, returns NULL. + const TestProperty* GetTestProperty(int i) const; + // Adds a test part result to the list. void AddTestPartResult(const TestPartResult& test_part_result); @@ -639,6 +651,10 @@ class TestCase { // Returns the elapsed time, in milliseconds. internal::TimeInMillis elapsed_time() const { return elapsed_time_; } + // 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. + const TestInfo* GetTestInfo(int i) const; + // Adds a TestInfo to this test case. Will delete the TestInfo upon // destruction of the TestCase object. void AddTestInfo(TestInfo * test_info); @@ -799,7 +815,50 @@ class UnitTest { // Accessors for the implementation object. internal::UnitTestImpl* impl() { return impl_; } const internal::UnitTestImpl* impl() const { return impl_; } + private: + // Gets the number of successful test cases. + int successful_test_case_count() const; + + // Gets the number of failed test cases. + int failed_test_case_count() const; + + // Gets the number of all test cases. + int total_test_case_count() const; + + // Gets the number of all test cases that contain at least one test + // that should run. + int test_case_to_run_count() const; + + // Gets the number of successful tests. + int successful_test_count() const; + + // Gets the number of failed tests. + int failed_test_count() const; + + // Gets the number of disabled tests. + int disabled_test_count() const; + + // Gets the number of all tests. + int total_test_count() const; + + // Gets the number of tests that should run. + int test_to_run_count() const; + + // Gets the elapsed time, in milliseconds. + internal::TimeInMillis elapsed_time() const; + + // Returns true iff the unit test passed (i.e. all test cases passed). + bool Passed() const; + + // Returns true iff the unit test failed (i.e. some test case failed + // or something outside of all tests failed). + bool Failed() const; + + // 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. + const internal::TestCase* GetTestCase(int i) const; + // ScopedTrace is a friend as it needs to modify the per-thread // trace stack, which is a private member of UnitTest. friend class internal::ScopedTrace; diff --git a/include/gtest/internal/gtest-tuple.h b/include/gtest/internal/gtest-tuple.h index be23e8e..5ef4920 100644 --- a/include/gtest/internal/gtest-tuple.h +++ b/include/gtest/internal/gtest-tuple.h @@ -38,18 +38,38 @@ #include <utility> // For ::std::pair. +// The compiler used in Symbian 5th Edition (__S60_50__) has a bug +// that prevents us from declaring the tuple template as a friend (it +// complains that tuple is redefined). This hack bypasses the bug by +// declaring the members that should otherwise be private as public. +#if defined(__SYMBIAN32__) && __S60_50__ +#define GTEST_DECLARE_TUPLE_AS_FRIEND_ public: +#else +#define GTEST_DECLARE_TUPLE_AS_FRIEND_ \ + template <GTEST_10_TYPENAMES_(U)> friend class tuple; \ + private: +#endif + // GTEST_n_TUPLE_(T) is the type of an n-tuple. #define GTEST_0_TUPLE_(T) tuple<> -#define GTEST_1_TUPLE_(T) tuple<T##0> -#define GTEST_2_TUPLE_(T) tuple<T##0, T##1> -#define GTEST_3_TUPLE_(T) tuple<T##0, T##1, T##2> -#define GTEST_4_TUPLE_(T) tuple<T##0, T##1, T##2, T##3> -#define GTEST_5_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4> -#define GTEST_6_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5> -#define GTEST_7_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6> -#define GTEST_8_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, T##7> +#define GTEST_1_TUPLE_(T) tuple<T##0, void, void, void, void, void, void, \ + void, void, void> +#define GTEST_2_TUPLE_(T) tuple<T##0, T##1, void, void, void, void, void, \ + void, void, void> +#define GTEST_3_TUPLE_(T) tuple<T##0, T##1, T##2, void, void, void, void, \ + void, void, void> +#define GTEST_4_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, void, void, void, \ + void, void, void> +#define GTEST_5_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, void, void, \ + void, void, void> +#define GTEST_6_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, void, \ + void, void, void> +#define GTEST_7_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \ + void, void, void> +#define GTEST_8_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \ + T##7, void, void> #define GTEST_9_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \ - T##7, T##8> + T##7, T##8, void> #define GTEST_10_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \ T##7, T##8, T##9> @@ -162,7 +182,6 @@ template <GTEST_1_TYPENAMES_(T)> class GTEST_1_TUPLE_(T) { public: template <int k> friend class gtest_internal::Get; - template <GTEST_10_TYPENAMES_(U)> friend class tuple; tuple() {} @@ -180,7 +199,8 @@ class GTEST_1_TUPLE_(T) { return CopyFrom(t); } - private: + GTEST_DECLARE_TUPLE_AS_FRIEND_ + template <GTEST_1_TYPENAMES_(U)> tuple& CopyFrom(const GTEST_1_TUPLE_(U)& t) { f0_ = t.f0_; @@ -194,7 +214,6 @@ template <GTEST_2_TYPENAMES_(T)> class GTEST_2_TUPLE_(T) { public: template <int k> friend class gtest_internal::Get; - template <GTEST_10_TYPENAMES_(U)> friend class tuple; tuple() {} @@ -221,7 +240,8 @@ class GTEST_2_TUPLE_(T) { return *this; } - private: + GTEST_DECLARE_TUPLE_AS_FRIEND_ + template <GTEST_2_TYPENAMES_(U)> tuple& CopyFrom(const GTEST_2_TUPLE_(U)& t) { f0_ = t.f0_; @@ -237,7 +257,6 @@ template <GTEST_3_TYPENAMES_(T)> class GTEST_3_TUPLE_(T) { public: template <int k> friend class gtest_internal::Get; - template <GTEST_10_TYPENAMES_(U)> friend class tuple; tuple() {} @@ -256,7 +275,8 @@ class GTEST_3_TUPLE_(T) { return CopyFrom(t); } - private: + GTEST_DECLARE_TUPLE_AS_FRIEND_ + template <GTEST_3_TYPENAMES_(U)> tuple& CopyFrom(const GTEST_3_TUPLE_(U)& t) { f0_ = t.f0_; @@ -274,7 +294,6 @@ template <GTEST_4_TYPENAMES_(T)> class GTEST_4_TUPLE_(T) { public: template <int k> friend class gtest_internal::Get; - template <GTEST_10_TYPENAMES_(U)> friend class tuple; tuple() {} @@ -295,7 +314,8 @@ class GTEST_4_TUPLE_(T) { return CopyFrom(t); } - private: + GTEST_DECLARE_TUPLE_AS_FRIEND_ + template <GTEST_4_TYPENAMES_(U)> tuple& CopyFrom(const GTEST_4_TUPLE_(U)& t) { f0_ = t.f0_; @@ -315,7 +335,6 @@ template <GTEST_5_TYPENAMES_(T)> class GTEST_5_TUPLE_(T) { public: template <int k> friend class gtest_internal::Get; - template <GTEST_10_TYPENAMES_(U)> friend class tuple; tuple() {} @@ -337,7 +356,8 @@ class GTEST_5_TUPLE_(T) { return CopyFrom(t); } - private: + GTEST_DECLARE_TUPLE_AS_FRIEND_ + template <GTEST_5_TYPENAMES_(U)> tuple& CopyFrom(const GTEST_5_TUPLE_(U)& t) { f0_ = t.f0_; @@ -359,7 +379,6 @@ template <GTEST_6_TYPENAMES_(T)> class GTEST_6_TUPLE_(T) { public: template <int k> friend class gtest_internal::Get; - template <GTEST_10_TYPENAMES_(U)> friend class tuple; tuple() {} @@ -382,7 +401,8 @@ class GTEST_6_TUPLE_(T) { return CopyFrom(t); } - private: + GTEST_DECLARE_TUPLE_AS_FRIEND_ + template <GTEST_6_TYPENAMES_(U)> tuple& CopyFrom(const GTEST_6_TUPLE_(U)& t) { f0_ = t.f0_; @@ -406,7 +426,6 @@ template <GTEST_7_TYPENAMES_(T)> class GTEST_7_TUPLE_(T) { public: template <int k> friend class gtest_internal::Get; - template <GTEST_10_TYPENAMES_(U)> friend class tuple; tuple() {} @@ -429,7 +448,8 @@ class GTEST_7_TUPLE_(T) { return CopyFrom(t); } - private: + GTEST_DECLARE_TUPLE_AS_FRIEND_ + template <GTEST_7_TYPENAMES_(U)> tuple& CopyFrom(const GTEST_7_TUPLE_(U)& t) { f0_ = t.f0_; @@ -455,7 +475,6 @@ template <GTEST_8_TYPENAMES_(T)> class GTEST_8_TUPLE_(T) { public: template <int k> friend class gtest_internal::Get; - template <GTEST_10_TYPENAMES_(U)> friend class tuple; tuple() {} @@ -479,7 +498,8 @@ class GTEST_8_TUPLE_(T) { return CopyFrom(t); } - private: + GTEST_DECLARE_TUPLE_AS_FRIEND_ + template <GTEST_8_TYPENAMES_(U)> tuple& CopyFrom(const GTEST_8_TUPLE_(U)& t) { f0_ = t.f0_; @@ -507,7 +527,6 @@ template <GTEST_9_TYPENAMES_(T)> class GTEST_9_TUPLE_(T) { public: template <int k> friend class gtest_internal::Get; - template <GTEST_10_TYPENAMES_(U)> friend class tuple; tuple() {} @@ -531,7 +550,8 @@ class GTEST_9_TUPLE_(T) { return CopyFrom(t); } - private: + GTEST_DECLARE_TUPLE_AS_FRIEND_ + template <GTEST_9_TYPENAMES_(U)> tuple& CopyFrom(const GTEST_9_TUPLE_(U)& t) { f0_ = t.f0_; @@ -561,7 +581,6 @@ template <GTEST_10_TYPENAMES_(T)> class tuple { public: template <int k> friend class gtest_internal::Get; - template <GTEST_10_TYPENAMES_(U)> friend class tuple; tuple() {} @@ -586,7 +605,8 @@ class tuple { return CopyFrom(t); } - private: + GTEST_DECLARE_TUPLE_AS_FRIEND_ + template <GTEST_10_TYPENAMES_(U)> tuple& CopyFrom(const GTEST_10_TUPLE_(U)& t) { f0_ = t.f0_; @@ -938,6 +958,7 @@ inline bool operator!=(const GTEST_10_TUPLE_(T)& t, #undef GTEST_9_TYPENAMES_ #undef GTEST_10_TYPENAMES_ +#undef GTEST_DECLARE_TUPLE_AS_FRIEND_ #undef GTEST_BY_REF_ #undef GTEST_ADD_REF_ #undef GTEST_TUPLE_ELEMENT_ diff --git a/include/gtest/internal/gtest-tuple.h.pump b/include/gtest/internal/gtest-tuple.h.pump index 33fd6b6..12821d8 100644 --- a/include/gtest/internal/gtest-tuple.h.pump +++ b/include/gtest/internal/gtest-tuple.h.pump @@ -39,15 +39,29 @@ $$ This meta comment fixes auto-indentation in Emacs. }} #include <utility> // For ::std::pair. +// The compiler used in Symbian 5th Edition (__S60_50__) has a bug +// that prevents us from declaring the tuple template as a friend (it +// complains that tuple is redefined). This hack bypasses the bug by +// declaring the members that should otherwise be private as public. +#if defined(__SYMBIAN32__) && __S60_50__ +#define GTEST_DECLARE_TUPLE_AS_FRIEND_ public: +#else +#define GTEST_DECLARE_TUPLE_AS_FRIEND_ \ + template <GTEST_$(n)_TYPENAMES_(U)> friend class tuple; \ + private: +#endif + $range i 0..n-1 $range j 0..n $range k 1..n // GTEST_n_TUPLE_(T) is the type of an n-tuple. +#define GTEST_0_TUPLE_(T) tuple<> -$for j [[ -$range m 0..j-1 -#define GTEST_$(j)_TUPLE_(T) tuple<$for m, [[T##$m]]> +$for k [[ +$range m 0..k-1 +$range m2 k..n-1 +#define GTEST_$(k)_TUPLE_(T) tuple<$for m, [[T##$m]]$for m2 [[, void]]> ]] @@ -125,7 +139,6 @@ template <GTEST_$(k)_TYPENAMES_(T)> class $if k < n [[GTEST_$(k)_TUPLE_(T)]] $else [[tuple]] { public: template <int k> friend class gtest_internal::Get; - template <GTEST_$(n)_TYPENAMES_(U)> friend class tuple; tuple() {} @@ -160,7 +173,8 @@ $if k == 2 [[ ]] - private: + GTEST_DECLARE_TUPLE_AS_FRIEND_ + template <GTEST_$(k)_TYPENAMES_(U)> tuple& CopyFrom(const GTEST_$(k)_TUPLE_(U)& t) { @@ -313,6 +327,7 @@ $for j [[ ]] +#undef GTEST_DECLARE_TUPLE_AS_FRIEND_ #undef GTEST_BY_REF_ #undef GTEST_ADD_REF_ #undef GTEST_TUPLE_ELEMENT_ |