diff --git a/exml/internal/Document.h b/exml/internal/Document.h index 475e2bb..7a73003 100644 --- a/exml/internal/Document.h +++ b/exml/internal/Document.h @@ -33,6 +33,7 @@ namespace exml { * @brief Enable or diasable the case sensitive (must be done before the call of parsing) * @param[in] _val true if enable; false else. */ + // TODO: Naming error, it is insensitive ... virtual void setCaseSensitive(bool _val) { m_caseSensitive = _val; }; diff --git a/lutin_exml-test.py b/lutin_exml-test.py index 592d063..c47a1f4 100644 --- a/lutin_exml-test.py +++ b/lutin_exml-test.py @@ -31,7 +31,18 @@ def get_maintainer(): def create(target, module_name): my_module = module.Module(__file__, module_name, get_type()) my_module.add_src_file([ - 'test/main.cpp' + 'test/main.cpp', + 'test/exmlTestAll.cpp', + 'test/exmlTestComment.cpp', + 'test/exmlTestElement.cpp', + 'test/exmlTestAttribute.cpp', + 'test/exmlTestCommon.cpp', + 'test/exmlTestDeclaration.cpp', + 'test/exmlTestDeclarationXML.cpp', + 'test/exmlTestParseComment.cpp', + 'test/exmlTestParseElement.cpp', + 'test/exmlTestParseAttribute.cpp', + 'test/exmlTestParseDeclaration.cpp' ]) my_module.add_module_depend(['exml', 'gtest', 'test-debug']) return my_module diff --git a/test/exmlTestAll.h b/test/exmlTestAll.cpp similarity index 64% rename from test/exmlTestAll.h rename to test/exmlTestAll.cpp index 81d0fee..e769319 100644 --- a/test/exmlTestAll.h +++ b/test/exmlTestAll.cpp @@ -1,11 +1,10 @@ -/** +/** @file * @author Edouard DUPIN * * @copyright 2014, Edouard DUPIN, all right reserved * * @license APACHE v2.0 (see license file) */ -#pragma once #include "exmlTestCommon.h" #include @@ -38,4 +37,20 @@ TEST(TestAll, testError) { 1); } +TEST(TestAll, testCaseSensitive) { + exmlLocalTest( "\n" + " \n" + " \n" + " Text example ...\n" + "\n", + "< exemple\n >\n" + " \n" + " \n" + " \n" + " Text example ...\n" + " \n" + "\n", + 1, + false); +} diff --git a/test/exmlTestAttribute.cpp b/test/exmlTestAttribute.cpp new file mode 100644 index 0000000..e5bff81 --- /dev/null +++ b/test/exmlTestAttribute.cpp @@ -0,0 +1,31 @@ +/** @file + * @author Edouard DUPIN + * + * @copyright 2014, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ + +#include +#include +#include + + +TEST(TestAttribute, create) { + exml::Attribute myAttribute("nameAttribute", "valueAttribute"); + EXPECT_EQ(myAttribute.getType(), exml::nodeType_attribute); +} + +TEST(TestAttribute, createCopy) { + exml::Attribute myAttribute("nameAttribute", "valueAttribute"); + exml::Attribute myOtherAttribute(myAttribute); + //EXPECT_EQ(myAttribute, myOtherAttribute); +} + +TEST(TestAttribute, createAssignement) { + exml::Attribute myAttribute("nameAttribute", "valueAttribute"); + exml::Attribute myOtherAttribute = myAttribute; + //EXPECT_EQ(myAttribute, myOtherAttribute); +} + + diff --git a/test/exmlTestComment.cpp b/test/exmlTestComment.cpp new file mode 100644 index 0000000..d32ed3e --- /dev/null +++ b/test/exmlTestComment.cpp @@ -0,0 +1,28 @@ +/** @file + * @author Edouard DUPIN + * + * @copyright 2014, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ + +#include +#include +#include + +TEST(TestComment, create) { + exml::Comment myComment("my Comment"); + EXPECT_EQ(myComment.getType(), exml::nodeType_comment); +} + +TEST(TestComment, createCopy) { + exml::Comment myComment("my Comment"); + exml::Comment myOtherComment(myComment); + //EXPECT_EQ(myComment, myOtherComment); +} + +TEST(TestComment, createAssignement) { + exml::Comment myComment("my comment"); + exml::Comment myOtherComment = myComment; + //EXPECT_EQ(myComment, myOtherComment); +} \ No newline at end of file diff --git a/test/exmlTestCommon.cpp b/test/exmlTestCommon.cpp new file mode 100644 index 0000000..c25a0de --- /dev/null +++ b/test/exmlTestCommon.cpp @@ -0,0 +1,44 @@ +/** @file + * @author Edouard DUPIN + * + * @copyright 2014, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ + +#include +#include +#include +#include + +// _errorPos : -1 : no error , 1 : parsing error, 2 generation error, 3 comparaison error ???? +void exmlLocalTest(const std::string& _ref, + const std::string& _input, + int32_t _errorPos, + bool _caseInSensitive=false) { + exml::Document doc; + //doc.setCaseSensitive(!_caseInSensitive); + //EXML_DEBUG("parse : \n" << l_list[iii].m_input); + bool retParse = doc.parse(_input); + if (_errorPos == 1) { + EXPECT_EQ(retParse, false); + return; + } else { + EXPECT_EQ(retParse, true); + } + std::string out(""); + bool retGenerate = doc.generate(out); + if (_errorPos == 2) { + EXPECT_EQ(retGenerate, false); + return; + } else { + EXPECT_EQ(retGenerate, true); + } + if (_errorPos == 3) { + EXPECT_NE(_ref, out); + return; + } else { + EXPECT_EQ(_ref, out); + } +} + diff --git a/test/exmlTestCommon.h b/test/exmlTestCommon.h index 59e2a74..929f8e3 100644 --- a/test/exmlTestCommon.h +++ b/test/exmlTestCommon.h @@ -1,4 +1,4 @@ -/** +/** @file * @author Edouard DUPIN * * @copyright 2014, Edouard DUPIN, all right reserved @@ -8,33 +8,10 @@ #pragma once #include -#include -#include // _errorPos : -1 : no error , 1 : parsing error, 2 generation error, 3 comparaison error ???? -static void exmlLocalTest(const std::string& _ref, const std::string& _input, int32_t _errorPos) { - exml::Document doc; - //EXML_DEBUG("parse : \n" << l_list[iii].m_input); - bool retParse = doc.parse(_input); - if (_errorPos == 1) { - EXPECT_EQ(retParse, false); - return; - } else { - EXPECT_EQ(retParse, true); - } - std::string out(""); - bool retGenerate = doc.generate(out); - if (_errorPos == 2) { - EXPECT_EQ(retGenerate, false); - return; - } else { - EXPECT_EQ(retGenerate, true); - } - if (_errorPos == 3) { - EXPECT_NE(_ref, out); - return; - } else { - EXPECT_EQ(_ref, out); - } -} +void exmlLocalTest(const std::string& _ref, + const std::string& _input, + int32_t _errorPos, + bool _caseInSensitive=false); diff --git a/test/exmlTestDeclaration.cpp b/test/exmlTestDeclaration.cpp new file mode 100644 index 0000000..17a0ecf --- /dev/null +++ b/test/exmlTestDeclaration.cpp @@ -0,0 +1,29 @@ +/** @file + * @author Edouard DUPIN + * + * @copyright 2014, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ + +#include +#include +#include + +TEST(TestDeclaration, create) { + exml::Declaration myDeclaration("type"); + EXPECT_EQ(myDeclaration.getType(), exml::nodeType_declaration); +} + +TEST(TestDeclaration, createCopy) { + exml::Declaration myDeclaration("type"); + exml::Declaration myOtherDeclaration(myDeclaration); + //EXPECT_EQ(myDeclaration, myOtherDeclaration); +} + +TEST(TestDeclaration, createAssignement) { + exml::Declaration myDeclaration("type"); + exml::Declaration myOtherDeclaration = myDeclaration; + //EXPECT_EQ(myDeclaration, myOtherDeclaration); +} + diff --git a/test/exmlTestDeclarationXML.cpp b/test/exmlTestDeclarationXML.cpp new file mode 100644 index 0000000..78892fc --- /dev/null +++ b/test/exmlTestDeclarationXML.cpp @@ -0,0 +1,29 @@ +/** @file + * @author Edouard DUPIN + * + * @copyright 2014, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ + +#include +#include +#include + +TEST(TestDeclarationXML, create) { + exml::DeclarationXML myDeclarationXML("1.0", "UTF-8", true); + EXPECT_EQ(myDeclarationXML.getType(), exml::nodeType_declaration); +} + +TEST(TestDeclarationXML, createCopy) { + exml::DeclarationXML myDeclarationXML("1.0", "UTF-8", true); + exml::DeclarationXML myOtherDeclarationXML(myDeclarationXML); + //EXPECT_EQ(myDeclarationXML, myOtherDeclarationXML); +} + +TEST(TestDeclarationXML, createAssignement) { + exml::DeclarationXML myDeclarationXML("1.0", "UTF-8", true); + exml::DeclarationXML myOtherDeclarationXML = myDeclarationXML; + //EXPECT_EQ(myDeclarationXML, myOtherDeclarationXML); +} + diff --git a/test/exmlTestElement.cpp b/test/exmlTestElement.cpp new file mode 100644 index 0000000..e8bd9c9 --- /dev/null +++ b/test/exmlTestElement.cpp @@ -0,0 +1,30 @@ +/** @file + * @author Edouard DUPIN + * + * @copyright 2014, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ + +#include +#include +#include + + +TEST(TestElement, create) { + exml::Element myElement("NodeName"); + //EXPECT_EQ(myElement.getType(), exml::nodeType_element); +} + +TEST(TestElement, createCopy) { + exml::Element myElement("NodeName"); + exml::Element myOtherElement(myElement); + //EXPECT_EQ(myElement, myOtherElement); +} + +TEST(TestElement, createAssignement) { + exml::Element myElement("NodeName"); + exml::Element myOtherElement = myElement; + //EXPECT_EQ(myElement, myOtherElement); +} + diff --git a/test/exmlTestAttribute.h b/test/exmlTestParseAttribute.cpp similarity index 64% rename from test/exmlTestAttribute.h rename to test/exmlTestParseAttribute.cpp index 027c19e..94fe881 100644 --- a/test/exmlTestAttribute.h +++ b/test/exmlTestParseAttribute.cpp @@ -1,58 +1,71 @@ -/** +/** @file * @author Edouard DUPIN * * @copyright 2014, Edouard DUPIN, all right reserved * * @license APACHE v2.0 (see license file) */ -#pragma once #include "exmlTestCommon.h" #include -TEST(TestAttribute, testBase) { + +TEST(TestParseAttribute, testBase) { exmlLocalTest("\n", "\n", -1); } -TEST(TestAttribute, testNoQuote) { +TEST(TestParseAttribute, testNoQuote) { exmlLocalTest("\n", "\n", -1); } -TEST(TestAttribute, testNoQuoteNumber) { +TEST(TestParseAttribute, testNoQuoteNumber) { exmlLocalTest("\n", "\n", -1); } -TEST(TestAttribute, testSpace1) { +TEST(TestParseAttribute, testSpace1) { exmlLocalTest("\n", "\n", -1); } -TEST(TestAttribute, testSpace2) { +TEST(TestParseAttribute, testSpace2) { exmlLocalTest("\n", "\n", -1); } -TEST(TestAttribute, testMultiline) { +TEST(TestParseAttribute, testMultiline) { exmlLocalTest("\n", "\n", -1); } -TEST(TestAttribute, testMultilineNoQuote) { +TEST(TestParseAttribute, testMultilineNoQuote) { exmlLocalTest("\n", "\n", -1); } -TEST(TestAttribute, testEmptyAttribute) { +TEST(TestParseAttribute, testEmptyAttribute) { exmlLocalTest("\n", "\n", -1); } -TEST(TestAttribute, testEmptyAttributeNoQuote) { +TEST(TestParseAttribute, testEmptyAttributeNoQuote) { exmlLocalTest("\n", "\n", -1); } + +TEST(TestParseAttribute, testEndAttributeError) { + exmlLocalTest("", + "\n", + 1); +} diff --git a/test/exmlTestComment.h b/test/exmlTestParseComment.cpp similarity index 71% rename from test/exmlTestComment.h rename to test/exmlTestParseComment.cpp index 39e9235..ddd7209 100644 --- a/test/exmlTestComment.h +++ b/test/exmlTestParseComment.cpp @@ -1,38 +1,38 @@ -/** +/** @file * @author Edouard DUPIN * * @copyright 2014, Edouard DUPIN, all right reserved * * @license APACHE v2.0 (see license file) */ -#pragma once #include "exmlTestCommon.h" #include -TEST(TestComment, testBase) { + +TEST(TestParseComment, testBase) { exmlLocalTest("\n", "\n", -1); } -TEST(TestComment, testMultiline) { +TEST(TestParseComment, testMultiline) { exmlLocalTest("\n", "\n", -1); } -TEST(TestComment, testTiretInComment) { +TEST(TestParseComment, testTiretInComment) { exmlLocalTest("\n", "\n", -1); } -TEST(TestComment, testWrongEndParsing) { +TEST(TestParseComment, testWrongEndParsing) { exmlLocalTest(" exemple-->\n", " exemple -->\n", -1); } -TEST(TestComment, testMultipleEnd) { +TEST(TestParseComment, testMultipleEnd) { exmlLocalTest("\n", " exemple -->\n", 1); } -TEST(TestComment, testEndError) { +TEST(TestParseComment, testEndError) { exmlLocalTest("\n", "\n", "\n", -1); } -TEST(TestComment, testAll) { +TEST(TestParseComment, testAll) { exmlLocalTest("\n", "\n", -1); diff --git a/test/exmlTestDeclaration.h b/test/exmlTestParseDeclaration.cpp similarity index 70% rename from test/exmlTestDeclaration.h rename to test/exmlTestParseDeclaration.cpp index 33204de..3a01f8a 100644 --- a/test/exmlTestDeclaration.h +++ b/test/exmlTestParseDeclaration.cpp @@ -1,38 +1,38 @@ -/** +/** @file * @author Edouard DUPIN * * @copyright 2014, Edouard DUPIN, all right reserved * * @license APACHE v2.0 (see license file) */ -#pragma once #include "exmlTestCommon.h" #include -TEST(TestDeclaration, testBase) { + +TEST(TestParseDeclaration, testBase) { exmlLocalTest("\n", "\n", -1); } -TEST(TestDeclaration, testAttribute) { +TEST(TestParseDeclaration, testAttribute) { exmlLocalTest("\n", "\n", -1); } -TEST(TestDeclaration, testNoQuote) { +TEST(TestParseDeclaration, testNoQuote) { exmlLocalTest("\n", "\n", -1); } -TEST(TestDeclaration, testNumberNoQuote) { +TEST(TestParseDeclaration, testNumberNoQuote) { exmlLocalTest("\n", "\n", -1); } -TEST(TestDeclaration, testSpace1) { +TEST(TestParseDeclaration, testSpace1) { exmlLocalTest("\n", "\n", -1); } -TEST(TestDeclaration, testSpace2) { +TEST(TestParseDeclaration, testSpace2) { exmlLocalTest("\n", "\n", -1); } -TEST(TestDeclaration, testMultiline) { +TEST(TestParseDeclaration, testMultiline) { exmlLocalTest("\n", "\n", -1); } -TEST(TestDeclaration, testAll) { +TEST(TestParseDeclaration, testAll) { exmlLocalTest("\n", "\n", -1); } diff --git a/test/exmlTestElement.h b/test/exmlTestParseElement.cpp similarity index 67% rename from test/exmlTestElement.h rename to test/exmlTestParseElement.cpp index c286ac8..344f6d5 100644 --- a/test/exmlTestElement.h +++ b/test/exmlTestParseElement.cpp @@ -1,11 +1,10 @@ -/** +/** @file * @author Edouard DUPIN * * @copyright 2014, Edouard DUPIN, all right reserved * * @license APACHE v2.0 (see license file) */ -#pragma once #include "exmlTestCommon.h" #include @@ -13,44 +12,44 @@ static std::string refOutputElement("\n"); -TEST(TestElement, testBase) { +TEST(TestParseElement, testBase) { exmlLocalTest(refOutputElement, "\n", -1); } -TEST(TestElement, testMultiline) { +TEST(TestParseElement, testMultiline) { exmlLocalTest(refOutputElement, "< \t\r exemple/>\n", -1); } -TEST(TestElement, testMultilineMultiTabbed) { +TEST(TestParseElement, testMultilineMultiTabbed) { exmlLocalTest(refOutputElement, "< \t\r exemple \t\r\r\r\n \t\t />\n", -1); } -TEST(TestElement, testWrongStart) { +TEST(TestParseElement, testWrongStart) { exmlLocalTest(refOutputElement, "< exemple < >\n", 1); } -TEST(TestElement, testMultipleSlash) { +TEST(TestParseElement, testMultipleSlash) { exmlLocalTest(refOutputElement, "< exemple / />\n", 1); } -TEST(TestElement, testExclamationPresence) { +TEST(TestParseElement, testExclamationPresence) { exmlLocalTest(refOutputElement, "< exemple ? />\n", 1); } -TEST(TestElement, testStarPresence) { +TEST(TestParseElement, testStarPresence) { exmlLocalTest(refOutputElement, "< exemple * />\n", 1); } -TEST(TestElement, testDotPresent) { +TEST(TestParseElement, testDotPresent) { exmlLocalTest(refOutputElement, "< . exemple < />\n", 1); } -TEST(TestElement, testWrong1) { +TEST(TestParseElement, testWrong1) { exmlLocalTest(refOutputElement, "\n", 1); } -TEST(TestElement, testWrong2) { +TEST(TestParseElement, testWrong2) { exmlLocalTest(refOutputElement, "\n", 1); } -TEST(TestElement, testWrong3) { +TEST(TestParseElement, testWrong3) { exmlLocalTest(refOutputElement, "< exemple < />\n", 1); } -TEST(TestElement, testBase2) { +TEST(TestParseElement, testBase2) { exmlLocalTest("\n", "\n", 1); } -TEST(TestElement, testBase3) { +TEST(TestParseElement, testBase3) { exmlLocalTest("\n", "\n\n", 1); } diff --git a/test/main.cpp b/test/main.cpp index ee76eb2..11bf062 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -7,17 +7,10 @@ */ #include -#include #include #include #include -//#include "exmlTestDocument.h" -#include "exmlTestElement.h" -#include "exmlTestAttribute.h" -#include "exmlTestDeclaration.h" -#include "exmlTestAll.h" - int main(int argc, const char *argv[]) { // init Google test : ::testing::InitGoogleTest(&argc, const_cast(argv));