Update contrib.
9 #include "cppunit/cppunit_proxy.h"
11 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
18 class SetUnionTest : public CPPUNIT_NS::TestCase
20 CPPUNIT_TEST_SUITE(SetUnionTest);
21 CPPUNIT_TEST(setunon0);
22 CPPUNIT_TEST(setunon1);
23 CPPUNIT_TEST(setunon2);
24 CPPUNIT_TEST_SUITE_END();
32 CPPUNIT_TEST_SUITE_REGISTRATION(SetUnionTest);
35 // tests implementation
37 void SetUnionTest::setunon0()
39 int v1[3] = { 13, 18, 23 };
40 int v2[4] = { 10, 13, 17, 23 };
41 int result[7] = { 0, 0, 0, 0, 0, 0, 0 };
43 set_union((int*)v1, (int*)v1 + 3, (int*)v2, (int*)v2 + 4, (int*)result);
45 CPPUNIT_ASSERT(result[0]==10);
46 CPPUNIT_ASSERT(result[1]==13);
47 CPPUNIT_ASSERT(result[2]==17);
48 CPPUNIT_ASSERT(result[3]==18);
49 CPPUNIT_ASSERT(result[4]==23);
50 CPPUNIT_ASSERT(result[5]==0);
51 CPPUNIT_ASSERT(result[6]==0);
54 void SetUnionTest::setunon1()
57 __iota(v1.begin(), v1.end(), 0);
59 __iota(v2.begin(), v2.end(), 7);
62 set_union(v1.begin(), v1.end(), v2.begin(), v2.end(), back_inserter(diff));
63 CPPUNIT_ASSERT( diff.size() == 17 );
64 for (int i = 0; i < 17; ++i) {
65 CPPUNIT_ASSERT( diff[i] == i );
69 void SetUnionTest::setunon2()
71 char* word1 = "ABCDEFGHIJKLMNO";
72 char* word2 = "LMNOPQRSTUVWXYZ";
75 set_union(word1, word1 + ::strlen(word1), word2, word2 + ::strlen(word2),
76 back_inserter(diff), less<char>());
77 CPPUNIT_ASSERT( diff.size() == 26 );
78 for (int i = 0; i < 26; ++i) {
79 CPPUNIT_ASSERT( diff[i] == ('A' + i) );