summaryrefslogtreecommitdiff
path: root/src/gtest-internal-inl.h
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-06-24 23:02:50 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-06-24 23:02:50 +0000
commit9644db857432db95bc64f5d6db5867b1c7cf1679 (patch)
treec0e3cbdc428e9461fa43b7f7d28636179ef0917a /src/gtest-internal-inl.h
parentb9a1628577f7ab2eb30a656aeff763909770c9c1 (diff)
downloadgtest-9644db857432db95bc64f5d6db5867b1c7cf1679.tar.gz
gtest-9644db857432db95bc64f5d6db5867b1c7cf1679.tar.bz2
gtest-9644db857432db95bc64f5d6db5867b1c7cf1679.tar.xz
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).
git-svn-id: http://googletest.googlecode.com/svn/trunk@275 861a406c-534a-0410-8894-cb66d6ee9925
Diffstat (limited to 'src/gtest-internal-inl.h')
-rw-r--r--src/gtest-internal-inl.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/gtest-internal-inl.h b/src/gtest-internal-inl.h
index 589be02..3abe9a2 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<E>* 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<E>* head_; // The first node of the list.
ListNode<E>* 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();