summaryrefslogtreecommitdiffstats
path: root/src/usr/testcore/lib
diff options
context:
space:
mode:
authorAndrew Geissler <andrewg@us.ibm.com>2016-03-11 08:46:44 -0600
committerA. P. Williams III <iawillia@us.ibm.com>2016-03-17 11:44:46 -0400
commit71cf29da3d308290ffd860fb263b4a05ddcb364a (patch)
treed8ff026c8cb8eb2d1beff2adadbbd118549c9e56 /src/usr/testcore/lib
parent497d9f20a3bc65847435c82358b32cd2cd6d6951 (diff)
downloadtalos-hostboot-71cf29da3d308290ffd860fb263b4a05ddcb364a.tar.gz
talos-hostboot-71cf29da3d308290ffd860fb263b4a05ddcb364a.zip
Need to implement new Ctor for std::vector
Change-Id: Ia7743dc8d3a83b4be361626b1dea57f39e4dd483 RTC: 149398 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/21938 Tested-by: Jenkins Server Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com> Reviewed-by: A. P. Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/testcore/lib')
-rw-r--r--src/usr/testcore/lib/stl_functional.H91
1 files changed, 88 insertions, 3 deletions
diff --git a/src/usr/testcore/lib/stl_functional.H b/src/usr/testcore/lib/stl_functional.H
index 5aac940f0..4b3fe6ea0 100644
--- a/src/usr/testcore/lib/stl_functional.H
+++ b/src/usr/testcore/lib/stl_functional.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2014 */
+/* Contributors Listed Below - COPYRIGHT 2014,2016 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -28,6 +28,8 @@
#include <cxxtest/TestSuite.H>
#include <functional>
#include <vector>
+#include <list>
+#include <initializer_list>
static bool STLFunctionalTest__matches1(int i)
{
@@ -42,7 +44,7 @@ static bool STLFunctionalTest__matches(int n, int m)
class STLFunctionalTest : public CxxTest::TestSuite
{
public:
- void testUnaryPtrFun()
+ void test_UnaryPtrFun()
{
using std::ptr_fun;
@@ -57,7 +59,7 @@ class STLFunctionalTest : public CxxTest::TestSuite
}
}
- void testBinaryPtrFun()
+ void test_BinaryPtrFun()
{
using std::ptr_fun;
using std::vector;
@@ -84,6 +86,89 @@ class STLFunctionalTest : public CxxTest::TestSuite
}
}
}
+
+ void test_InitializerListVectorFun()
+ {
+ using std::vector;
+
+ vector<uint32_t> v {0,1,2,3,4};
+ uint32_t VEC_SIZE = 5;
+
+ TS_TRACE("max size of vector v is %d",v.max_size());
+ TS_TRACE("BEGIN: size of vector v is %d",v.size());
+
+ if(v.size() != VEC_SIZE)
+ {
+ TS_FAIL("Size not equal to expected value expected:%d "
+ "actual:%d!",
+ VEC_SIZE,v.size());
+ }
+
+ for(uint32_t i=0;i<VEC_SIZE;i++)
+ {
+ if (v[i] != i)
+ {
+ TS_FAIL("Vector array index %d is not equal to %d, "
+ "it is %d",
+ i,i,v[i]);
+ }
+ }
+
+ // Pop a couple off
+ v.pop_back();
+ v.pop_back();
+
+ if(v.size() != (VEC_SIZE-2))
+ {
+ TS_FAIL("pop_back did not reduce size as expected!");
+ }
+
+ // Add some back
+ v.push_back(100);
+ v.push_back(99);
+
+ if(v.size() != VEC_SIZE)
+ {
+ TS_FAIL("Size not equal to expected value expected:%d "
+ "actual:%d after pop and push!",
+ VEC_SIZE,v.size());
+ }
+
+ TS_TRACE("END: size of vector v is %d",v.size());
+ }
+
+ void test_InitializerListFun()
+ {
+ using std::list;
+ std::list<uint32_t> l = {0,1,2,3,4};
+
+ uint32_t LIST_SIZE = 5;
+ if(l.size() != LIST_SIZE)
+ {
+ TS_FAIL("Size not equal to expected value expected:%d "
+ "actual:%d!",
+ LIST_SIZE,l.size());
+ }
+
+ for(uint32_t i=0;i<LIST_SIZE;i++)
+ {
+ if (l.front() != i)
+ {
+ TS_FAIL("Index %d is not equal to %d, "
+ "it is %d",
+ i,i,l.front());
+ }
+ l.pop_front();
+ }
+
+ if(l.size() != 0)
+ {
+ TS_FAIL("List size not equal to 0 like it should be! %d",
+ l.size());
+ }
+
+ }
+
};
#endif
OpenPOWER on IntegriCloud