Revert "Roll NDK to r11c and extract it into its own repository."
[android_tools.git] / ndk / tests / device / test-stlport / unit / inplace_test.cpp
blob2c9bd99c399f2c12dd0d99b17ee5f16b7ca6ae11
1 #include <vector>
2 #include <algorithm>
3 #include <functional>
5 #include "cppunit/cppunit_proxy.h"
7 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
8 using namespace std;
9 #endif
12 // TestCase class
14 class InplaceTest : public CPPUNIT_NS::TestCase
16 CPPUNIT_TEST_SUITE(InplaceTest);
17 CPPUNIT_TEST(inplmrg1);
18 CPPUNIT_TEST(inplmrg2);
19 CPPUNIT_TEST_SUITE_END();
21 protected:
22 void inplmrg1();
23 void inplmrg2();
26 CPPUNIT_TEST_SUITE_REGISTRATION(InplaceTest);
29 // tests implementation
31 void InplaceTest::inplmrg1()
33 int numbers[6] = { 1, 10, 42, 3, 16, 32 };
34 inplace_merge(numbers, numbers + 3, numbers + 6);
36 CPPUNIT_ASSERT(numbers[0]==1);
37 CPPUNIT_ASSERT(numbers[1]==3);
38 CPPUNIT_ASSERT(numbers[2]==10);
39 CPPUNIT_ASSERT(numbers[3]==16);
40 CPPUNIT_ASSERT(numbers[4]==32);
41 CPPUNIT_ASSERT(numbers[5]==42);
43 void InplaceTest::inplmrg2()
45 vector<size_t> v1(10);
46 for(size_t i = 0; i < v1.size(); ++i)
47 v1[i] =(v1.size() - i - 1) % 5;
49 inplace_merge(v1.begin(), v1.begin() + 5, v1.end(), greater<size_t>());
51 CPPUNIT_ASSERT(v1[0]==4);
52 CPPUNIT_ASSERT(v1[1]==4);
53 CPPUNIT_ASSERT(v1[2]==3);
54 CPPUNIT_ASSERT(v1[3]==3);
55 CPPUNIT_ASSERT(v1[4]==2);
56 CPPUNIT_ASSERT(v1[5]==2);
57 CPPUNIT_ASSERT(v1[6]==1);
58 CPPUNIT_ASSERT(v1[7]==1);
59 CPPUNIT_ASSERT(v1[8]==0);
60 CPPUNIT_ASSERT(v1[9]==0);