From 9b242f31eeead492b12f39dfebd23e97328b1da9 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Thu, 26 Feb 2015 16:26:53 +0100
Subject: [PATCH] fix prim. string from "...", pars.bool and string

---
 alib2data/src/XmlApi.cpp                      |  1 -
 alib2data/src/XmlApi.hpp                      |  1 -
 alib2data/src/alphabet/Symbol.cpp             |  6 +-
 alib2data/src/alphabet/Symbol.h               |  3 +-
 alib2data/src/automaton/common/State.cpp      |  3 +
 alib2data/src/automaton/common/State.h        |  1 +
 alib2data/src/label/Label.cpp                 |  6 +-
 alib2data/src/label/Label.h                   |  3 +-
 alib2data/src/primitive/Primitive.cpp         |  6 +-
 alib2data/src/primitive/Primitive.h           |  3 +-
 .../src/primitive/PrimitiveFromXMLParser.cpp  |  6 +-
 .../src/primitive/PrimitiveToXMLComposer.cpp  |  8 +--
 alib2data/src/primitive/String.cpp            |  4 ++
 alib2data/src/primitive/String.h              |  2 +
 alib2data/src/regexp/RegExp.cpp               |  4 ++
 alib2data/src/regexp/RegExp.h                 |  2 +
 alib2data/src/sax/SaxComposeInterface.cpp     | 58 +++++++++----------
 alib2data/src/string/CyclicString.cpp         |  3 +
 alib2data/src/string/CyclicString.h           |  1 +
 alib2data/src/string/LinearString.cpp         |  3 +
 alib2data/src/string/LinearString.h           |  1 +
 alib2data/src/string/String.cpp               |  4 ++
 alib2data/src/string/String.h                 |  1 +
 .../test-src/primitive/PrimitiveTest.cpp      | 47 +++++++++++++++
 alib2data/test-src/primitive/PrimitiveTest.h  | 19 ++++++
 25 files changed, 153 insertions(+), 43 deletions(-)
 create mode 100644 alib2data/test-src/primitive/PrimitiveTest.cpp
 create mode 100644 alib2data/test-src/primitive/PrimitiveTest.h

diff --git a/alib2data/src/XmlApi.cpp b/alib2data/src/XmlApi.cpp
index 30ee8856de..ce6c606d94 100644
--- a/alib2data/src/XmlApi.cpp
+++ b/alib2data/src/XmlApi.cpp
@@ -93,7 +93,6 @@ const std::string Names::REGEXP_FORMAL_REGEXP = "FormalRegExp";
 const std::string Names::STRING_LINEAR_STRING = "LinearString";
 const std::string Names::STRING_CYCLIC_STRING = "CyclicString";
 const std::string Names::STRING_EPSILON = "Epsilon";
-const std::string Names::PRIMITIVE_PRIMITIVE = "Primitive";
 const std::string Names::PRIMITIVE_STRING = "String";
 const std::string Names::PRIMITIVE_INTEGER = "Integer";
 const std::string Names::PRIMITIVE_CHARACTER = "Character";
diff --git a/alib2data/src/XmlApi.hpp b/alib2data/src/XmlApi.hpp
index 65e8d82ab7..1c4b5f54fd 100644
--- a/alib2data/src/XmlApi.hpp
+++ b/alib2data/src/XmlApi.hpp
@@ -94,7 +94,6 @@ public:
 	const static std::string STRING_LINEAR_STRING;
 	const static std::string STRING_CYCLIC_STRING;
 	const static std::string STRING_EPSILON;
-	const static std::string PRIMITIVE_PRIMITIVE;
 	const static std::string PRIMITIVE_STRING;
 	const static std::string PRIMITIVE_INTEGER;
 	const static std::string PRIMITIVE_CHARACTER;
diff --git a/alib2data/src/alphabet/Symbol.cpp b/alib2data/src/alphabet/Symbol.cpp
index 4d8dae2132..9fd53443cc 100644
--- a/alib2data/src/alphabet/Symbol.cpp
+++ b/alib2data/src/alphabet/Symbol.cpp
@@ -36,9 +36,13 @@ alphabet::Symbol symbolFrom( char character ) {
 	return alphabet::Symbol { alphabet::LabeledSymbol { label::labelFrom ( character ) } };
 }
 
-alphabet::Symbol symbolFrom( std::string string ) {
+alphabet::Symbol symbolFrom( const std::string& string ) {
 	return alphabet::Symbol { alphabet::LabeledSymbol { label::labelFrom ( string ) } };
 }
 
+alphabet::Symbol symbolFrom( const char* string ) {
+	return symbolFrom( (std::string) string );
+}
+
 } /* namespace alphabet */
 
diff --git a/alib2data/src/alphabet/Symbol.h b/alib2data/src/alphabet/Symbol.h
index 6b7883c14b..ec8fddcfd9 100644
--- a/alib2data/src/alphabet/Symbol.h
+++ b/alib2data/src/alphabet/Symbol.h
@@ -34,7 +34,8 @@ alphabet::Symbol createUniqueSymbol(const alphabet::Symbol& base, const std::set
 
 alphabet::Symbol symbolFrom(int number);
 alphabet::Symbol symbolFrom(char character);
-alphabet::Symbol symbolFrom(std::string string);
+alphabet::Symbol symbolFrom(const std::string& string);
+alphabet::Symbol symbolFrom(const char* string);
 
 } /* namespace alphabet */
 
diff --git a/alib2data/src/automaton/common/State.cpp b/alib2data/src/automaton/common/State.cpp
index 6f5319aa42..a1ae066da0 100644
--- a/alib2data/src/automaton/common/State.cpp
+++ b/alib2data/src/automaton/common/State.cpp
@@ -25,6 +25,9 @@ State::State(char character) : name(label::labelFrom(character)) {
 State::State(const std::string& name) : name(label::labelFrom(name)) {
 }
 
+State::State(const char* name) : State((std::string) name) {
+}
+
 const label::Label& State::getName() const {
 	return name;
 }
diff --git a/alib2data/src/automaton/common/State.h b/alib2data/src/automaton/common/State.h
index dfa4b9bd8a..f3a1512a84 100644
--- a/alib2data/src/automaton/common/State.h
+++ b/alib2data/src/automaton/common/State.h
@@ -27,6 +27,7 @@ public:
 	explicit State(int number);
 	explicit State(char character);
 	explicit State(const std::string& name);
+	explicit State(const char* name);
 
 	const label::Label& getName() const;
 
diff --git a/alib2data/src/label/Label.cpp b/alib2data/src/label/Label.cpp
index 05af029c78..c5500fd1b4 100644
--- a/alib2data/src/label/Label.cpp
+++ b/alib2data/src/label/Label.cpp
@@ -19,9 +19,13 @@ label::Label labelFrom(char character) {
 	return label::Label { label::PrimitiveLabel { primitive::primitiveFrom ( character ) } };
 }
 
-label::Label labelFrom(std::string string) {
+label::Label labelFrom(const std::string& string) {
 	return label::Label { label::PrimitiveLabel { primitive::primitiveFrom ( string ) } };
 }
 
+label::Label labelFrom(const char* string) {
+	return labelFrom((std::string) string);
+}
+
 } /* namespace label */
 
diff --git a/alib2data/src/label/Label.h b/alib2data/src/label/Label.h
index feddac9c51..3201b4419d 100644
--- a/alib2data/src/label/Label.h
+++ b/alib2data/src/label/Label.h
@@ -22,7 +22,8 @@ typedef alib::wrapper<LabelBase> Label;
 
 label::Label labelFrom(int number);
 label::Label labelFrom(char character);
-label::Label labelFrom(std::string string);
+label::Label labelFrom(const std::string& string);
+label::Label labelFrom(const char* string);
 
 } /* namespace label */
 
diff --git a/alib2data/src/primitive/Primitive.cpp b/alib2data/src/primitive/Primitive.cpp
index 24b9f9cf2e..b6695aecbc 100644
--- a/alib2data/src/primitive/Primitive.cpp
+++ b/alib2data/src/primitive/Primitive.cpp
@@ -22,7 +22,11 @@ Primitive primitiveFrom(char character) {
 	return Primitive { Character { character } };
 }
 
-Primitive primitiveFrom(std::string string) {
+Primitive primitiveFrom(const char* string) {
+	return primitiveFrom((std::string) string);
+}
+
+Primitive primitiveFrom(const std::string& string) {
 	return Primitive { String { string } };
 }
 
diff --git a/alib2data/src/primitive/Primitive.h b/alib2data/src/primitive/Primitive.h
index 5deca51ced..731b106825 100644
--- a/alib2data/src/primitive/Primitive.h
+++ b/alib2data/src/primitive/Primitive.h
@@ -22,7 +22,8 @@ typedef alib::wrapper<PrimitiveBase> Primitive;
 
 Primitive primitiveFrom(int number);
 Primitive primitiveFrom(char character);
-Primitive primitiveFrom(std::string string);
+Primitive primitiveFrom(const std::string& string);
+Primitive primitiveFrom(const char* string);
 Primitive primitiveFrom(unsigned number);
 Primitive primitiveFrom(bool value);
 
diff --git a/alib2data/src/primitive/PrimitiveFromXMLParser.cpp b/alib2data/src/primitive/PrimitiveFromXMLParser.cpp
index 7c687adcec..04c9533882 100644
--- a/alib2data/src/primitive/PrimitiveFromXMLParser.cpp
+++ b/alib2data/src/primitive/PrimitiveFromXMLParser.cpp
@@ -63,9 +63,11 @@ Character PrimitiveFromXMLParser::parseCharacter(std::list<sax::Token>& input) c
 
 String PrimitiveFromXMLParser::parseString(std::list<sax::Token>& input) const {
 	popToken(input, sax::Token::TokenType::START_ELEMENT, alib::Names::PRIMITIVE_STRING);
-	String data(popTokenData(input, sax::Token::TokenType::CHARACTER));
+	std::string data = "";
+	if( isTokenType(input, sax::Token::TokenType::CHARACTER))
+		data = popTokenData(input, sax::Token::TokenType::CHARACTER);
 	popToken(input, sax::Token::TokenType::END_ELEMENT, alib::Names::PRIMITIVE_STRING);
-	return data;
+	return String(data);
 }
 
 Unsigned PrimitiveFromXMLParser::parseUnsigned(std::list<sax::Token>& input) const {
diff --git a/alib2data/src/primitive/PrimitiveToXMLComposer.cpp b/alib2data/src/primitive/PrimitiveToXMLComposer.cpp
index 948d0c5088..83a3361c69 100644
--- a/alib2data/src/primitive/PrimitiveToXMLComposer.cpp
+++ b/alib2data/src/primitive/PrimitiveToXMLComposer.cpp
@@ -45,9 +45,9 @@ void PrimitiveToXMLComposer::compose(std::list<sax::Token>& out, const Unsigned&
 void PrimitiveToXMLComposer::compose(std::list<sax::Token>& out, const Bool& primitive) const {
 	out.push_back(sax::Token(alib::Names::PRIMITIVE_BOOL, sax::Token::TokenType::START_ELEMENT));
 	if(primitive.getData())
-		out.push_back(sax::Token("true", sax::Token::TokenType::END_ELEMENT));
+		out.push_back(sax::Token("true", sax::Token::TokenType::CHARACTER));
 	else
-		out.push_back(sax::Token("false", sax::Token::TokenType::END_ELEMENT));
+		out.push_back(sax::Token("false", sax::Token::TokenType::CHARACTER));
 	out.push_back(sax::Token(alib::Names::PRIMITIVE_BOOL, sax::Token::TokenType::END_ELEMENT));
 }
 
@@ -84,9 +84,9 @@ void PrimitiveToXMLComposer::compose(std::list<sax::Token>& out, unsigned primit
 void PrimitiveToXMLComposer::compose(std::list<sax::Token>& out, bool primitive) const {
 	out.push_back(sax::Token(alib::Names::PRIMITIVE_BOOL, sax::Token::TokenType::START_ELEMENT));
 	if(primitive)
-		out.push_back(sax::Token("true", sax::Token::TokenType::END_ELEMENT));
+		out.push_back(sax::Token("true", sax::Token::TokenType::CHARACTER));
 	else
-		out.push_back(sax::Token("false", sax::Token::TokenType::END_ELEMENT));
+		out.push_back(sax::Token("false", sax::Token::TokenType::CHARACTER));
 	out.push_back(sax::Token(alib::Names::PRIMITIVE_BOOL, sax::Token::TokenType::END_ELEMENT));
 }
 
diff --git a/alib2data/src/primitive/String.cpp b/alib2data/src/primitive/String.cpp
index 5fcc6edb63..b9bbb6f58f 100644
--- a/alib2data/src/primitive/String.cpp
+++ b/alib2data/src/primitive/String.cpp
@@ -17,6 +17,10 @@ String::String(std::string&& data) : data(std::move(data)) {
 
 }
 
+String::String(const char* data) : String((std::string) data) {
+
+}
+
 PrimitiveBase* String::clone() const {
 	return new String(*this);
 }
diff --git a/alib2data/src/primitive/String.h b/alib2data/src/primitive/String.h
index 83bde177e8..0ceb083f34 100644
--- a/alib2data/src/primitive/String.h
+++ b/alib2data/src/primitive/String.h
@@ -31,6 +31,8 @@ public:
 
 	explicit String(std::string&& data);
 
+	explicit String(const char* data);
+
 	virtual PrimitiveBase* clone() const;
 
 	virtual PrimitiveBase* plunder() &&;
diff --git a/alib2data/src/regexp/RegExp.cpp b/alib2data/src/regexp/RegExp.cpp
index fde75f2fa7..b0081b93d8 100644
--- a/alib2data/src/regexp/RegExp.cpp
+++ b/alib2data/src/regexp/RegExp.cpp
@@ -21,6 +21,10 @@ regexp::RegExp regexpFrom( const std::string& string ) {
 	return regexp::RegExp { regexp::UnboundedRegExp ( con ) };
 }
 
+regexp::RegExp regexpFrom( const char* string ) {
+	return regexpFrom( (std::string) string );
+}
+
 regexp::RegExp regexpFrom( const string::LinearString& string ) {
 	regexp::UnboundedRegExpConcatenation con;
 	for(const auto& symbol : string.getContent()) {
diff --git a/alib2data/src/regexp/RegExp.h b/alib2data/src/regexp/RegExp.h
index 828ceb1b6f..7f03130121 100644
--- a/alib2data/src/regexp/RegExp.h
+++ b/alib2data/src/regexp/RegExp.h
@@ -25,6 +25,8 @@ typedef alib::wrapper<RegExpBase> RegExp;
 
 regexp::RegExp regexpFrom( const std::string& string );
 
+regexp::RegExp regexpFrom( const char* string );
+
 regexp::RegExp regexpFrom( const string::LinearString& string );
 
 regexp::RegExp regexpFrom( const alphabet::Symbol& symbol );
diff --git a/alib2data/src/sax/SaxComposeInterface.cpp b/alib2data/src/sax/SaxComposeInterface.cpp
index 7bff5bb5b2..353d478cc2 100644
--- a/alib2data/src/sax/SaxComposeInterface.cpp
+++ b/alib2data/src/sax/SaxComposeInterface.cpp
@@ -1,8 +1,8 @@
 /*
  * SaxComposeInterface.cpp
  *
- *  Created on: 8.8.2012
- *      Author: Martin Zak
+ *	Created on: 8.8.2012
+ *			Author: Martin Zak
  */
 
 #include "SaxComposeInterface.h"
@@ -19,9 +19,9 @@ namespace sax {
 void SaxComposeInterface::printMemory(std::string& xmlOut, const std::list<Token>& in) {
 	xmlBufferPtr buf = xmlBufferCreate();
 	xmlTextWriterPtr writer = xmlNewTextWriterMemory(buf, 0);
-	
+
 	SaxComposeInterface::xmlSAXUserPrint(writer, in);
-	
+
 	xmlFreeTextWriter(writer);
 	xmlOut = (const char*) buf->content;
 	xmlBufferFree(buf);
@@ -31,7 +31,7 @@ void SaxComposeInterface::printFile(const std::string& filename, const std::list
 	xmlTextWriterPtr writer = xmlNewTextWriterFilename(filename.c_str(), 0);
 
 	SaxComposeInterface::xmlSAXUserPrint(writer, in);
-	
+
 	xmlFreeTextWriter(writer);
 }
 
@@ -42,9 +42,9 @@ void SaxComposeInterface::printStdout(const std::list<Token>& in) {
 void SaxComposeInterface::printStream(std::ostream& out, const std::list<Token>& in) {
 	xmlBufferPtr buf = xmlBufferCreate();
 	xmlTextWriterPtr writer = xmlNewTextWriterMemory(buf, 0);
-	
+
 	SaxComposeInterface::xmlSAXUserPrint(writer, in);
-	
+
 	xmlFreeTextWriter(writer);
 	out << (const char*) buf->content;
 	xmlBufferFree(buf);
@@ -54,33 +54,33 @@ void SaxComposeInterface::xmlSAXUserPrint(xmlTextWriterPtr writer, const std::li
 	xmlTextWriterStartDocument(writer, NULL, NULL, NULL);
 	std::deque<Token> stack;
 	for(const Token& token : in) {
-	  switch(token.getType()) {
+		switch(token.getType()) {
 		case Token::TokenType::START_ELEMENT:
-		  xmlTextWriterStartElement(writer, (const xmlChar*) token.getData().c_str());
-		  stack.push_back(token);
-		  break;
+			xmlTextWriterStartElement(writer, (const xmlChar*) token.getData().c_str());
+			stack.push_back(token);
+			break;
 		case Token::TokenType::END_ELEMENT:
-		  if(stack.empty() || stack.back().getData() != token.getData() || stack.back().getType() != Token::TokenType::START_ELEMENT) {
-			throw ComposerException(Token(stack.back().getData(), Token::TokenType::END_ELEMENT), token);
-		  }
-		  stack.pop_back();
-		  xmlTextWriterEndElement(writer);
-		  break;
+			if(stack.empty() || stack.back().getData() != token.getData() || stack.back().getType() != Token::TokenType::START_ELEMENT) {
+				throw ComposerException(Token(stack.back().getData(), Token::TokenType::END_ELEMENT), token);
+			}
+			stack.pop_back();
+			xmlTextWriterEndElement(writer);
+			break;
 		case Token::TokenType::CHARACTER:
-		  xmlTextWriterWriteString(writer, (const xmlChar*) token.getData().c_str());
-		  break;
+			xmlTextWriterWriteString(writer, (const xmlChar*) token.getData().c_str());
+			break;
 		case Token::TokenType::START_ATTRIBUTE:
-		  xmlTextWriterStartAttribute(writer, (const xmlChar*) token.getData().c_str());
-		  stack.push_back(token);
-		  break;
+			xmlTextWriterStartAttribute(writer, (const xmlChar*) token.getData().c_str());
+			stack.push_back(token);
+			break;
 		case Token::TokenType::END_ATTRIBUTE:
-		  if(stack.empty() || stack.back().getData() != token.getData() || stack.back().getType() != Token::TokenType::START_ATTRIBUTE) {
-			throw ComposerException(Token(stack.back().getData(), Token::TokenType::END_ATTRIBUTE), token);
-		  }
-		  stack.pop_back();
-		  xmlTextWriterEndAttribute(writer);
-		  break;
-	  }
+			if(stack.empty() || stack.back().getData() != token.getData() || stack.back().getType() != Token::TokenType::START_ATTRIBUTE) {
+				throw ComposerException(Token(stack.back().getData(), Token::TokenType::END_ATTRIBUTE), token);
+			}
+			stack.pop_back();
+			xmlTextWriterEndAttribute(writer);
+			break;
+		}
 	}
 	xmlTextWriterEndDocument(writer);
 }
diff --git a/alib2data/src/string/CyclicString.cpp b/alib2data/src/string/CyclicString.cpp
index 640a5c77a9..443be9b159 100644
--- a/alib2data/src/string/CyclicString.cpp
+++ b/alib2data/src/string/CyclicString.cpp
@@ -50,6 +50,9 @@ CyclicString::CyclicString(const std::string& str) {
 	alphabet = std::set<alphabet::Symbol>(m_Data.begin(), m_Data.end());
 }
 
+CyclicString::CyclicString(const char* str) : CyclicString((std::string) str) {
+}
+
 CyclicString::CyclicString(const Epsilon& epsilon) {
 	alphabet = epsilon.getAlphabet();
 }
diff --git a/alib2data/src/string/CyclicString.h b/alib2data/src/string/CyclicString.h
index 2026c6f1d5..b45a41ba9a 100644
--- a/alib2data/src/string/CyclicString.h
+++ b/alib2data/src/string/CyclicString.h
@@ -33,6 +33,7 @@ public:
 	explicit CyclicString(const std::vector<alphabet::Symbol>& data);
 	explicit CyclicString(std::vector<alphabet::Symbol>&& data);
 	explicit CyclicString(const std::string& str);
+	explicit CyclicString(const char* str);
 	explicit CyclicString(const Epsilon& epsilon);
 
 	virtual StringBase* clone() const;
diff --git a/alib2data/src/string/LinearString.cpp b/alib2data/src/string/LinearString.cpp
index c02fde9bb2..856cfd2a7a 100644
--- a/alib2data/src/string/LinearString.cpp
+++ b/alib2data/src/string/LinearString.cpp
@@ -50,6 +50,9 @@ LinearString::LinearString(const std::string& str) {
 	alphabet = std::set<alphabet::Symbol>(m_Data.begin(), m_Data.end());
 }
 
+LinearString::LinearString(const char* str) : LinearString((std::string) str) {
+}
+
 LinearString::LinearString(const Epsilon& epsilon) {
 	alphabet = epsilon.getAlphabet();
 }
diff --git a/alib2data/src/string/LinearString.h b/alib2data/src/string/LinearString.h
index ee463d1ea4..05da8ee3d5 100644
--- a/alib2data/src/string/LinearString.h
+++ b/alib2data/src/string/LinearString.h
@@ -34,6 +34,7 @@ public:
 	explicit LinearString(const std::vector<alphabet::Symbol>& data);
 	explicit LinearString(std::vector<alphabet::Symbol>&& data);
 	explicit LinearString(const std::string& str);
+	explicit LinearString(const char* str);
 	explicit LinearString(const Epsilon& epsilon);
 
 	virtual StringBase* clone() const;
diff --git a/alib2data/src/string/String.cpp b/alib2data/src/string/String.cpp
index 8d08af4309..05368df250 100644
--- a/alib2data/src/string/String.cpp
+++ b/alib2data/src/string/String.cpp
@@ -19,5 +19,9 @@ string::String stringFrom( const std::string& string ) {
 	return string::String { string::LinearString { string } };
 }
 
+string::String stringFrom( const char* string ) {
+	return stringFrom( (std::string) string);
+}
+
 } /* namespace string */
 
diff --git a/alib2data/src/string/String.h b/alib2data/src/string/String.h
index 5d87b2f9bb..2ef1e18001 100644
--- a/alib2data/src/string/String.h
+++ b/alib2data/src/string/String.h
@@ -23,6 +23,7 @@ typedef alib::wrapper<StringBase> String;
 
 string::String stringFrom(const alphabet::Symbol& symbol);
 string::String stringFrom(const std::string& str);
+string::String stringFrom(const char* str);
 
 } /* namespace string */
 
diff --git a/alib2data/test-src/primitive/PrimitiveTest.cpp b/alib2data/test-src/primitive/PrimitiveTest.cpp
new file mode 100644
index 0000000000..e64cf8f66a
--- /dev/null
+++ b/alib2data/test-src/primitive/PrimitiveTest.cpp
@@ -0,0 +1,47 @@
+#include <list>
+#include "PrimitiveTest.h"
+
+#include "sax/SaxParseInterface.h"
+#include "sax/SaxComposeInterface.h"
+
+#include "primitive/Primitive.h"
+
+#include "factory/XmlDataFactory.hpp"
+#include "factory/StringDataFactory.hpp"
+#include <algorithm>
+
+#define CPPUNIT_EXCLUSIVE_OR(x, y) CPPUNIT_ASSERT((!(x) && (y)) || ((x) && !(y)))
+
+CPPUNIT_TEST_SUITE_REGISTRATION( PrimitiveTest );
+
+void PrimitiveTest::setUp() {
+}
+
+void PrimitiveTest::tearDown() {
+}
+
+void PrimitiveTest::testXMLParser() {
+
+	primitive::Primitive primitive = primitive::primitiveFrom("aaa");
+	std::cout << primitive << std::endl;
+
+	{
+		std::list<sax::Token> tokens = alib::XmlDataFactory::toTokens(primitive);
+		std::cout << tokens << std::endl;
+		std::string tmp;
+		sax::SaxComposeInterface::printMemory(tmp, tokens);
+
+		std::list<sax::Token> tokens2;
+		sax::SaxParseInterface::parseMemory(tmp, tokens2);
+		primitive::Primitive primitive2 = alib::XmlDataFactory::fromTokens<primitive::Primitive>(tokens2);
+
+		CPPUNIT_ASSERT( primitive == primitive2 );
+	}
+	{
+		std::string tmp = alib::XmlDataFactory::toString(primitive);
+		primitive::Primitive primitive2 = alib::XmlDataFactory::fromString<primitive::Primitive>(tmp);
+
+		CPPUNIT_ASSERT( primitive == primitive2 );
+	}
+}
+
diff --git a/alib2data/test-src/primitive/PrimitiveTest.h b/alib2data/test-src/primitive/PrimitiveTest.h
new file mode 100644
index 0000000000..e24b6ff857
--- /dev/null
+++ b/alib2data/test-src/primitive/PrimitiveTest.h
@@ -0,0 +1,19 @@
+#ifndef PRIMITIVE_TEST_H_
+#define PRIMITIVE_TEST_H_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class PrimitiveTest : public CppUnit::TestFixture
+{
+	CPPUNIT_TEST_SUITE( PrimitiveTest );
+	CPPUNIT_TEST( testXMLParser );
+	CPPUNIT_TEST_SUITE_END();
+
+public:
+	void setUp();
+	void tearDown();
+
+	void testXMLParser();
+};
+
+#endif	// PRIMITIVE_TEST_H_
-- 
GitLab