diff options
author | Matt Derksen <mderkse1@us.ibm.com> | 2019-08-22 09:21:13 -0500 |
---|---|---|
committer | Nicholas E Bofferding <bofferdn@us.ibm.com> | 2019-09-05 16:13:51 -0500 |
commit | 582ed66b307ef514742cd6c6cb5f50affe771699 (patch) | |
tree | e481dca81dfd8f1a46365da48056e695bab3fdf2 /src/usr/testcore/lib | |
parent | f7dab51ab5057e622495c5762ac3ba12b6d8b59f (diff) | |
download | talos-hostboot-582ed66b307ef514742cd6c6cb5f50affe771699.tar.gz talos-hostboot-582ed66b307ef514742cd6c6cb5f50affe771699.zip |
Implement std::begin() and std::end() for base types
begin() returns an iterator to first element in array.
end() returns an iterator to one past the last element in array.
Change-Id: Idf97d3fbcf361f8318b84aa95452fd4fa5809d6b
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/82665
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Christian R Geddes <crgeddes@us.ibm.com>
Reviewed-by: Glenn Miles <milesg@ibm.com>
Reviewed-by: Nicholas E Bofferding <bofferdn@us.ibm.com>
Diffstat (limited to 'src/usr/testcore/lib')
-rw-r--r-- | src/usr/testcore/lib/stltest.H | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/usr/testcore/lib/stltest.H b/src/usr/testcore/lib/stltest.H index 31cc3cbe9..34cb64d4a 100644 --- a/src/usr/testcore/lib/stltest.H +++ b/src/usr/testcore/lib/stltest.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2017 */ +/* Contributors Listed Below - COPYRIGHT 2011,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -782,5 +782,35 @@ class STLTest : public CxxTest::TestSuite } } + /// Test std::begin() and std::end() on base-type array + void testBaseTypeBeginEnd() + { + const int MAX_ENTRIES = 1025; + int baseA[MAX_ENTRIES] = {0}; // base-type array + + // Initialize base array to known values + for (int i = 0; i < MAX_ENTRIES; i++) + { + baseA[i] = i; + } + + // use std::begin() and std::end() to copy base-type array to vector + std::vector<int> baseV ( std::begin(baseA), std::end(baseA)); + + if (baseV.size() != MAX_ENTRIES) + { + TS_FAIL("testBaseTypeBeginEnd: expected %d elements, found %d in vector", + MAX_ENTRIES, baseV.size()); + } + + for (int i = 0; i < MAX_ENTRIES; i++) + { + if (baseA[i] != baseV[i]) + { + TS_FAIL("testBaseTypeBeginEnd: No match at index %d (base %d vs vector %d)", + i, baseA[i], baseV[i]); + } + } + } }; #endif |