9 #include "cppunit/cppunit_proxy.h"
11 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
18 class SetIntersectionTest
: public CPPUNIT_NS::TestCase
20 CPPUNIT_TEST_SUITE(SetIntersectionTest
);
21 CPPUNIT_TEST(setintr0
);
22 CPPUNIT_TEST(setintr1
);
23 CPPUNIT_TEST(setintr2
);
24 CPPUNIT_TEST_SUITE_END();
32 CPPUNIT_TEST_SUITE_REGISTRATION(SetIntersectionTest
);
35 // tests implementation
37 void SetIntersectionTest::setintr0()
39 int v1
[3] = { 13, 18, 23 };
40 int v2
[4] = { 10, 13, 17, 23 };
41 int result
[4] = { 0, 0, 0, 0 };
43 set_intersection((int*)v1
, (int*)v1
+ 3, (int*)v2
, (int*)v2
+ 4, (int*)result
);
45 CPPUNIT_ASSERT(result
[0]==13);
46 CPPUNIT_ASSERT(result
[1]==23);
47 CPPUNIT_ASSERT(result
[2]==0);
48 CPPUNIT_ASSERT(result
[3]==0);
51 void SetIntersectionTest::setintr1()
54 __iota(v1
.begin(), v1
.end(), 0);
56 __iota(v2
.begin(), v2
.end(), 7);
59 set_intersection(v1
.begin(), v1
.end(), v2
.begin(), v2
.end(), back_inserter(inter
));
60 CPPUNIT_ASSERT( inter
.size() == 3 );
61 CPPUNIT_ASSERT( inter
[0] == 7 );
62 CPPUNIT_ASSERT( inter
[1] == 8 );
63 CPPUNIT_ASSERT( inter
[2] == 9 );
66 void SetIntersectionTest::setintr2()
68 const char* word1
= "ABCDEFGHIJKLMNO";
69 const char* word2
= "LMNOPQRSTUVWXYZ";
72 set_intersection(word1
, word1
+ ::strlen(word1
), word2
, word2
+ ::strlen(word2
),
73 back_inserter(inter
), less
<char>());
74 CPPUNIT_ASSERT( inter
.size() == 4 );
75 CPPUNIT_ASSERT( inter
[0] == 'L' );
76 CPPUNIT_ASSERT( inter
[1] == 'M' );
77 CPPUNIT_ASSERT( inter
[2] == 'N' );
78 CPPUNIT_ASSERT( inter
[3] == 'O' );