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

test normalisation

parent 95b2eaed
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
#include "alphabet/LabeledSymbol.h" #include "alphabet/LabeledSymbol.h"
#include "alphabet/BlankSymbol.h" #include "alphabet/BlankSymbol.h"
   
#include <primitive/Character.h>
#include <container/ObjectsSet.h>
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( StringTest, "string" ); CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( StringTest, "string" );
CPPUNIT_TEST_SUITE_REGISTRATION ( StringTest ); CPPUNIT_TEST_SUITE_REGISTRATION ( StringTest );
   
...@@ -97,3 +100,63 @@ void StringTest::testStringInMap ( ) { ...@@ -97,3 +100,63 @@ void StringTest::testStringInMap ( ) {
CPPUNIT_ASSERT ( entry.first.get < string::Epsilon < > > ( ) == string::Epsilon < >::EPSILON ); CPPUNIT_ASSERT ( entry.first.get < string::Epsilon < > > ( ) == string::Epsilon < >::EPSILON );
} }
} }
void StringTest::testNormalize ( ) {
string::LinearString < char > raw ( std::vector < char > { 'a', 'b' } );
string::String s1 ( raw );
s1.normalize ( );
string::String s2 ( raw );
std::string tmp1 = alib::XmlDataFactory::toString ( s1 );
std::cout << tmp1 << std::endl;
string::String s1x = alib::XmlDataFactory::fromString ( tmp1 );
std::string tmp2 = alib::XmlDataFactory::toString ( s2 );
std::cout << tmp2 << std::endl;
string::String s2x = alib::XmlDataFactory::fromString ( tmp2 );
CPPUNIT_ASSERT ( s1x == s2x );
}
void StringTest::testNormalize2 ( ) {
string::LinearString < alib::Object > raw ( std::vector < alib::Object > { alib::Object ( 'a' ), alib::Object ( 'b' ) } );
string::String s1 ( raw );
s1.normalize ( );
string::String s2 ( raw );
std::string tmp1 = alib::XmlDataFactory::toString ( s1 );
std::cout << tmp1 << std::endl;
string::String s1x = alib::XmlDataFactory::fromString ( tmp1 );
std::string tmp2 = alib::XmlDataFactory::toString ( s2 );
std::cout << tmp2 << std::endl;
string::String s2x = alib::XmlDataFactory::fromString ( tmp2 );
CPPUNIT_ASSERT ( s1 == s1x );
CPPUNIT_ASSERT ( s1 == s2x );
}
void StringTest::testNormalize3 ( ) {
string::LinearString < std::set < char > > raw ( std::vector < std::set < char > > { std::set < char > { 'a' }, std::set < char > { 'b' } } );
string::String s1 ( raw );
s1.normalize ( );
string::String s2 ( raw );
std::string tmp1 = alib::XmlDataFactory::toString ( s1 );
std::cout << tmp1 << std::endl;
string::String s1x = alib::XmlDataFactory::fromString ( tmp1 );
std::string tmp2 = alib::XmlDataFactory::toString ( s2 );
std::cout << tmp2 << std::endl;
string::String s2x = alib::XmlDataFactory::fromString ( tmp2 );
CPPUNIT_ASSERT ( s1x == s2x );
string::LinearString < alib::Object > rawRef ( std::vector < alib::Object > { alib::Object ( container::ObjectsSet < alib::Object > ( std::set < alib::Object > { alib::Object ( primitive::Character ( 'a' ) ) } ) ), alib::Object ( container::ObjectsSet < alib::Object > ( std::set < alib::Object > { alib::Object ( primitive::Character ( 'b' ) ) } ) ) } );
string::String ref ( rawRef );
std::cout << s1x << std::endl;
std::cout << ref << std::endl;
CPPUNIT_ASSERT ( s1x == ref );
}
...@@ -9,6 +9,9 @@ class StringTest : public CppUnit::TestFixture ...@@ -9,6 +9,9 @@ class StringTest : public CppUnit::TestFixture
CPPUNIT_TEST( testCopyConstruct ); CPPUNIT_TEST( testCopyConstruct );
CPPUNIT_TEST( testXMLParser ); CPPUNIT_TEST( testXMLParser );
CPPUNIT_TEST( testStringInMap ); CPPUNIT_TEST( testStringInMap );
CPPUNIT_TEST( testNormalize );
CPPUNIT_TEST( testNormalize2 );
CPPUNIT_TEST( testNormalize3 );
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
   
public: public:
...@@ -18,6 +21,9 @@ public: ...@@ -18,6 +21,9 @@ public:
void testCopyConstruct(); void testCopyConstruct();
void testXMLParser(); void testXMLParser();
void testStringInMap(); void testStringInMap();
void testNormalize();
void testNormalize2();
void testNormalize3();
}; };
   
#endif // STRING_TEST_H_ #endif // STRING_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