From e6095deec89dcf5237948b3460d84a137622f16c Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Wed, 24 Jun 2009 23:02:50 +0000 Subject: 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). --- src/gtest-internal-inl.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/gtest-internal-inl.h') diff --git a/src/gtest-internal-inl.h b/src/gtest-internal-inl.h index 589be02e..3abe9a26 100644 --- a/src/gtest-internal-inl.h +++ b/src/gtest-internal-inl.h @@ -430,6 +430,26 @@ class List { return NULL; } + // Returns a pointer to the i-th element of the list, or NULL if i is not + // in range [0, size()). + const E* GetElement(int i) const { + if (i < 0 || i >= size()) + return NULL; + + const ListNode* node = Head(); + for (int index = 0; index < i && node != NULL; ++index, node = node->next()) + continue; + + return node ? &(node->element()) : NULL; + } + + // Returns the i-th element of the list, or default_value if i is not + // in range [0, size()). + E GetElementOr(int i, E default_value) const { + const E* element = GetElement(i); + return element ? *element : default_value; + } + private: ListNode* head_; // The first node of the list. ListNode* last_; // The last node of the list. @@ -765,6 +785,12 @@ class UnitTestImpl { return failed_test_case_count() > 0 || ad_hoc_test_result()->Failed(); } + // 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 TestCase* GetTestCase(int i) const { + return test_cases_.GetElementOr(i, NULL); + } + // Returns the TestResult for the test that's currently running, or // the TestResult for the ad hoc test if no test is running. internal::TestResult* current_test_result(); -- cgit v1.2.3