Skip to content
Snippets Groups Projects
Commit 4cefcd02 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

more detailed set_symmetric_difference test

parent e91180e3
No related branches found
No related tags found
No related merge requests found
#include "AlgorithmTest.h" #include "AlgorithmTest.h"
#include <alib/algorithm> #include <alib/algorithm>
#include <alib/set> #include <alib/set>
#include <alib/vector>
   
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( AlgorithmTest, "bits" ); CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( AlgorithmTest, "bits" );
CPPUNIT_TEST_SUITE_REGISTRATION( AlgorithmTest ); CPPUNIT_TEST_SUITE_REGISTRATION( AlgorithmTest );
...@@ -139,3 +140,19 @@ void AlgorithmTest::testFindRange ( ) { ...@@ -139,3 +140,19 @@ void AlgorithmTest::testFindRange ( ) {
CPPUNIT_ASSERT ( range.second - str.begin ( ) == 14 ); CPPUNIT_ASSERT ( range.second - str.begin ( ) == 14 );
} }
} }
void AlgorithmTest::testSymmetricDifference ( ) {
ext::set < int > a { 1, 3, 5, 6, 7, 8, 9 };
ext::set < int > b { 1, 2, 3, 4, 5, 7, 8 };
ext::vector < int > a_b { 6, 9 };
ext::vector < int > b_a { 2, 4 };
ext::vector < int > a_b2;
ext::vector < int > b_a2;
ext::set_symmetric_difference ( a.begin ( ), a.end ( ), b.begin ( ), b.end ( ), std::back_inserter ( a_b2 ), std::back_inserter ( b_a2 ) );
CPPUNIT_ASSERT ( a_b == a_b2 );
CPPUNIT_ASSERT ( b_a == b_a2 );
}
...@@ -9,6 +9,7 @@ class AlgorithmTest : public CppUnit::TestFixture ...@@ -9,6 +9,7 @@ class AlgorithmTest : public CppUnit::TestFixture
CPPUNIT_TEST( testExclude ); CPPUNIT_TEST( testExclude );
CPPUNIT_TEST( testTransform ); CPPUNIT_TEST( testTransform );
CPPUNIT_TEST( testFindRange ); CPPUNIT_TEST( testFindRange );
CPPUNIT_TEST( testSymmetricDifference );
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
   
public: public:
...@@ -18,6 +19,7 @@ public: ...@@ -18,6 +19,7 @@ public:
void testExclude(); void testExclude();
void testTransform(); void testTransform();
void testFindRange(); void testFindRange();
void testSymmetricDifference ( );
}; };
   
#endif // ALGORITHM_TEST_H_ #endif // ALGORITHM_TEST_H_
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment