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

labelInSet test

parent 4d843349
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "label/LabelToXMLComposer.h" #include "label/LabelToXMLComposer.h"
   
#include "factory/DataFactory.hpp" #include "factory/DataFactory.hpp"
#include <algorithm>
   
#define CPPUNIT_EXCLUSIVE_OR(x, y) CPPUNIT_ASSERT((!(x) && (y)) || ((x) && !(y))) #define CPPUNIT_EXCLUSIVE_OR(x, y) CPPUNIT_ASSERT((!(x) && (y)) || ((x) && !(y)))
   
...@@ -145,3 +146,32 @@ void LabelTest::testOrder() { ...@@ -145,3 +146,32 @@ void LabelTest::testOrder() {
CPPUNIT_EXCLUSIVE_OR( s1 < c1, c1 < s1); CPPUNIT_EXCLUSIVE_OR( s1 < c1, c1 < s1);
} }
   
void LabelTest::testInSet() {
{
std::set<std::string> set1 { "a", "b", "c" };
std::set<std::string> set2 { "a" };
std::set<std::string> set3;
std::set_difference(set1.begin(), set1.end(), set2.begin(), set2.end(), std::insert_iterator<std::set<std::string>>(set3, set3.begin()));
for(const auto& item : set2) {
set1.erase(item);
}
CPPUNIT_ASSERT(set1.size() == 2);
CPPUNIT_ASSERT(set3.size() == 2);
}
{
std::set<label::Label> set1 { label::labelFrom('a'), label::labelFrom('b'), label::labelFrom('c') };
std::set<label::Label> set2 { label::labelFrom('a') };
std::set<label::Label> set3;
std::set_difference(set1.begin(), set1.end(), set2.begin(), set2.end(), std::insert_iterator<std::set<label::Label>>(set3, set3.begin()));
for(const auto& item : set2) {
set1.erase(item);
}
CPPUNIT_ASSERT(set1.size() == 2);
CPPUNIT_ASSERT(set3.size() == 2);
}
}
...@@ -10,6 +10,7 @@ class LabelTest : public CppUnit::TestFixture ...@@ -10,6 +10,7 @@ class LabelTest : public CppUnit::TestFixture
CPPUNIT_TEST( testEqual ); CPPUNIT_TEST( testEqual );
CPPUNIT_TEST( testXMLParser ); CPPUNIT_TEST( testXMLParser );
CPPUNIT_TEST( testOrder ); CPPUNIT_TEST( testOrder );
CPPUNIT_TEST( testInSet );
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
   
public: public:
...@@ -20,6 +21,7 @@ public: ...@@ -20,6 +21,7 @@ public:
void testEqual(); void testEqual();
void testXMLParser(); void testXMLParser();
void testOrder(); void testOrder();
void testInSet();
}; };
   
#endif // LABEL_TEST_H_ #endif // LABEL_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