Win32 console application "TestXmlCheckWithBoostExtensions.exe" demonstrates the running of a unit test with Boost.Test lib and performing of XML checks using TestToolBox::XmlCheck, TestToolBox::TestEvents. More...
Win32 console application "TestXmlCheckWithBoostExtensions.exe" demonstrates the running of a unit test with Boost.Test lib and performing of XML checks using TestToolBox::XmlCheck, TestToolBox::TestEvents.
Supported features
Depends on
Typical code snippets
TTB::TheXmlCheck()->IgnoreAttribute("date"); TTB::TheXmlCheck()->IgnoreAttribute("time"); TTB::TheXmlCheck()->IgnoreNode("date"); TTB::TheXmlCheck()->UseAsDoubleAttribute("tolerance", true, 3); TTB::TheXmlCheck()->UseAsDoubleNode("x", true, 4); TTB::TheXmlCheck()->CheckNode(&doc);
TTB_EXP("MyContainer"); TTB_EXP(" Group_A"); TTB_EXP(" Vector"); TTB_EXP(" id: 1"); TTB_EXP(" tolerance: 0.026"); TTB_EXP(" This is the text of the first vector element"); TTB_EXP(" x"); TTB_EXP(" 3.1424"); TTB_EXP(" Vector"); TTB_EXP(" id: 2"); TTB_EXP(" tolerance: 0.026"); TTB_EXP(" This is the text of the second vector element"); TTB_EXP(" x"); TTB_EXP(" 1.3264");
TTB::TheXmlCheck()->CheckSubNode(doc.RootElement(),""/MyContainer/Group_A/Vector[last()]");
TTB_EXP("Vector"); TTB_EXP(" id: 3"); TTB_EXP(" tolerance: 1.357"); TTB_EXP(" x"); TTB_EXP(" 6.28532");
TTB::TheXmlCheck()->IgnoreAttribute("time"); TTB::TheXmlCheck()->Compare(&docA,&docB);
TTB_EXP("Difference detected"); TTB_EXP("A: tolerance: 0.0258 (line: 7 col: 54, path: //MyContainer/Group_A/Vector)"); TTB_EXP("B: tolerance: 0.8258 (line: 9 col: 54, path: //MyContainer/Group_A/Vector)");
TTB::TheXmlCheck()->Compare( TTB::XmlCheck::SubNodeFromXPath(docA.RootElement(), "/MyContainer/Group_B"), TTB::XmlCheck::SubNodeFromXPath(docB.RootElement(), "/MyContainer/Group_B"));
TTB_EXP("Difference detected"); TTB_EXP("A: 3.132437 (line: 18 col: 8, path: //MyContainer/Group_B/x/3.132437/)"); TTB_EXP("B: 12.132437 (line: 20 col: 8, path: //MyContainer/Group_B/x/12.132437/)");
Project settings
../../..;C:/;C:/boost/boost_actual
tinyxpathd.lib
C:/TinyXPath/tinyxpath_lib/Debug;C:/boost/boost_actual/lib;
/NODEFAULTLIB:LIBCMTD.lib
Hints for execution
TTB::TestEvents::Get()->LogCallsToAct(true);
Log: Running without "--log_level=test_suite"
Running 4 test cases... No errors detected
Log: Running with "--log_level=test_suite" and default setting "LogCallsToAct(false)"
Running 4 test cases... Entering test suite "Master Test Suite" Entering test case "SetupTestEnv" Test case SetupTestEnv doesn't include any assertions Leaving test case "SetupTestEnv" Entering test case "TestCheckNode" ______________________________________________ Testcases for CheckNode ______________________________________________ ---- TEST_EVENT next section: "Examples how to get an XmlNode from an XML string or an XML file" now doc and docFromFile should contain the same XML data ---- TEST_EVENT next section: "CheckNode" Remark: Within this test environment XmlCheck is connected with TestEvents via XmlCheck::SetEventReceiver(TTB::TestEvents::Get()). CheckNode() writes all entries to TestEvents, but this class doesn't use the context entry. Therefore the context set by XmlCheck()::SetOutputModeForWritingXmlContents is not relevant. ---- TEST_EVENT next section: CheckNode - detailed output ---- TEST_EVENT next section: "CheckNode - ignore attributes and nodes, define double values with precision" Ignore attributes 'date' and 'time' and node 'date' Attribute 'tolerance' is a double with precision 3 Node 'x' is a double with precision 4 ---- TEST_EVENT next section: "CheckNode - ignore complete subtree 'Group_A' " Furthermore set precision for 'x' to 1 ---- TEST_EVENT next section: "CheckSubNode with XPath - only Group_B (/MyContainer/Group_B)" ---- TEST_EVENT next section: "CheckSubNode with XPath - first x element within Group_B (/MyContainer/Group_B/x)" ---- TEST_EVENT next section: "CheckSubNode with XPath - third x element within Group_B (/MyContainer/Group_B/x[3])" ---- TEST_EVENT next section: "CheckSubNode with XPath - second vector element of Group_A (/MyContainer/Group_A/Vector[2])" ---- TEST_EVENT next section: "CheckSubNode with XPath - last vector element of Group_A (/MyContainer/Group_A/Vector[last()])" ---- TEST_EVENT next section: "CheckSubNode with XPath - relative to subtree via SubNodeFromXPath (/MyContainer/Group_A, Vector[last())" ---- TEST_EVENT check section Leaving test case "TestCheckNode"; testing time: 31ms Entering test case "TestCompare" ---- TEST_EVENT next section: "Compare - with/without use of TestEvents)" Comparing two XML trees without differences (with TestEvents) Comparing two XML trees without differences (without TestEvents) XML-Compare: no differences found Comparing two XML trees without differences - now suppressing OK message ---- TEST_EVENT next section: "Compare - detection of first difference" ---- TEST_EVENT next section: "Compare - ignoring 'time'" ---- TEST_EVENT next section: "Compare - using XPath to compare subtrees (/MyContainer/Group_B)" For more test cases see also projects TestXmlCheckBasic,TestXmlCheckWithExtensionsForBoost ---- TEST_EVENT check section Leaving test case "TestCompare"; testing time: 47ms Entering test case "Cleanup" Test case Cleanup doesn't include any assertions Leaving test case "Cleanup" Leaving test suite "Master Test Suite" No errors detected
Log: Running with "LogCallsToAct(true)" and "--log_level=test_suite"
Running 4 test cases... Entering test suite "Master Test Suite" Entering test case "SetupTestEnv" Test case SetupTestEnv doesn't include any assertions Leaving test case "SetupTestEnv" Entering test case "TestCheckNode" ______________________________________________ Testcases for CheckNode ______________________________________________ ---- TEST_EVENT next section: "Examples how to get an XmlNode from an XML string or an XML file" now doc and docFromFile should contain the same XML data ---- TEST_EVENT next section: "CheckNode" Remark: Within this test environment XmlCheck is connected with TestEvents via XmlCheck::SetEventReceiver(TTB::TestEvents::Get()). CheckNode() writes all entries to TestEvents, but this class doesn't use the context entry. Therefore the context set by XmlCheck()::SetOutputModeForWritingXmlContents is not relevant. TEST_EVENT: INFO: Act: TTB_EXP("MyContainer"); TEST_EVENT: INFO: Act: TTB_EXP(" Group_A"); TEST_EVENT: INFO: Act: TTB_EXP(" Vector"); TEST_EVENT: INFO: Act: TTB_EXP(" id: 1"); TEST_EVENT: INFO: Act: TTB_EXP(" date: 01.07.09"); TEST_EVENT: INFO: Act: TTB_EXP(" time: 09:15:12.234"); TEST_EVENT: INFO: Act: TTB_EXP(" tolerance: 0.0258"); TEST_EVENT: INFO: Act: TTB_EXP(" This is the text of the first vector element"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 3.14235"); TEST_EVENT: INFO: Act: TTB_EXP(" Vector"); TEST_EVENT: INFO: Act: TTB_EXP(" id: 2"); TEST_EVENT: INFO: Act: TTB_EXP(" date: 01.07.09"); TEST_EVENT: INFO: Act: TTB_EXP(" time: 09:15:12.234"); TEST_EVENT: INFO: Act: TTB_EXP(" tolerance: 0.0258"); TEST_EVENT: INFO: Act: TTB_EXP(" This is the text of the second vector element"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 3.14235"); TEST_EVENT: INFO: Act: TTB_EXP(" Vector"); TEST_EVENT: INFO: Act: TTB_EXP(" id: 3"); TEST_EVENT: INFO: Act: TTB_EXP(" tolerance: 1.357"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 6.28532"); TEST_EVENT: INFO: Act: TTB_EXP(" Group_B"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 1.23456"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 2.3581"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 3.132437"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 4.987654"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 5.29741"); TEST_EVENT: INFO: Act: TTB_EXP(" Group_C"); TEST_EVENT: INFO: Act: TTB_EXP(" Interior"); TEST_EVENT: INFO: Act: TTB_EXP(" Something"); TEST_EVENT: INFO: Act: TTB_EXP(" Some text"); TEST_EVENT: INFO: Act: TTB_EXP(" date"); TEST_EVENT: INFO: Act: TTB_EXP(" 28.09.09"); ---- TEST_EVENT next section: CheckNode - detailed output TEST_EVENT: INFO: Act: TTB_EXP("Document (line: 1, col: 1)"); TEST_EVENT: INFO: Act: TTB_EXP("Element: MyContainer (line: 1, col: 1)"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: Group_A (line: 2, col: 5)"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: Vector (line: 3, col: 9)"); TEST_EVENT: INFO: Act: TTB_EXP(" id: 1, as int: 1, as double: 1 (line: 3, col: 17)"); TEST_EVENT: INFO: Act: TTB_EXP(" date: 01.07.09, as int: 1, as double: 1.07 (line: 3, col: 24)"); TEST_EVENT: INFO: Act: TTB_EXP(" time: 09:15:12.234, as int: 9, as double: 9 (line: 3, col: 40)"); TEST_EVENT: INFO: Act: TTB_EXP(" tolerance: 0.0258, as int: 0, as double: 0.0258 (line: 3, col: 60)"); TEST_EVENT: INFO: Act: TTB_EXP(" 4 attributes"); TEST_EVENT: INFO: Act: TTB_EXP(" Text: This is the text of the first vector element (line: 3, col: 79)"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: x (line: 4, col: 13)"); TEST_EVENT: INFO: Act: TTB_EXP(" Text: 3.14235 (line: 4, col: 16)"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: Vector (line: 6, col: 9)"); TEST_EVENT: INFO: Act: TTB_EXP(" id: 2, as int: 2, as double: 2 (line: 6, col: 17)"); TEST_EVENT: INFO: Act: TTB_EXP(" date: 01.07.09, as int: 1, as double: 1.07 (line: 6, col: 24)"); TEST_EVENT: INFO: Act: TTB_EXP(" time: 09:15:12.234, as int: 9, as double: 9 (line: 6, col: 40)"); TEST_EVENT: INFO: Act: TTB_EXP(" tolerance: 0.0258, as int: 0, as double: 0.0258 (line: 6, col: 60)"); TEST_EVENT: INFO: Act: TTB_EXP(" 4 attributes"); TEST_EVENT: INFO: Act: TTB_EXP(" Text: This is the text of the second vector element (line: 6, col: 79)"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: x (line: 7, col: 13)"); TEST_EVENT: INFO: Act: TTB_EXP(" Text: 3.14235 (line: 7, col: 16)"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: Vector (line: 9, col: 9)"); TEST_EVENT: INFO: Act: TTB_EXP(" id: 3, as int: 3, as double: 3 (line: 9, col: 17)"); TEST_EVENT: INFO: Act: TTB_EXP(" tolerance: 1.357, as int: 1, as double: 1.357 (line: 9, col: 24)"); TEST_EVENT: INFO: Act: TTB_EXP(" 2 attributes"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: x (line: 10, col: 13)"); TEST_EVENT: INFO: Act: TTB_EXP(" Text: 6.28532 (line: 10, col: 16)"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: Group_B (line: 13, col: 5)"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: x (line: 14, col: 9)"); TEST_EVENT: INFO: Act: TTB_EXP(" Text: 1.23456 (line: 14, col: 12)"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: x (line: 15, col: 9)"); TEST_EVENT: INFO: Act: TTB_EXP(" Text: 2.3581 (line: 15, col: 12)"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: x (line: 16, col: 9)"); TEST_EVENT: INFO: Act: TTB_EXP(" Text: 3.132437 (line: 16, col: 12)"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: x (line: 17, col: 9)"); TEST_EVENT: INFO: Act: TTB_EXP(" Text: 4.987654 (line: 17, col: 12)"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: x (line: 18, col: 9)"); TEST_EVENT: INFO: Act: TTB_EXP(" Text: 5.29741 (line: 18, col: 12)"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: Group_C (line: 20, col: 5)"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: Interior (line: 21, col: 9)"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: Something (line: 22, col: 13)"); TEST_EVENT: INFO: Act: TTB_EXP(" Text: Some text (line: 22, col: 24)"); TEST_EVENT: INFO: Act: TTB_EXP(" Element: date (line: 23, col: 13)"); TEST_EVENT: INFO: Act: TTB_EXP(" Text: 28.09.09 (line: 23, col: 19)"); ---- TEST_EVENT next section: "CheckNode - ignore attributes and nodes, define double values with precision" Ignore attributes 'date' and 'time' and node 'date' Attribute 'tolerance' is a double with precision 3 Node 'x' is a double with precision 4 TEST_EVENT: INFO: Act: TTB_EXP("MyContainer"); TEST_EVENT: INFO: Act: TTB_EXP(" Group_A"); TEST_EVENT: INFO: Act: TTB_EXP(" Vector"); TEST_EVENT: INFO: Act: TTB_EXP(" id: 1"); TEST_EVENT: INFO: Act: TTB_EXP(" tolerance: 0.026"); TEST_EVENT: INFO: Act: TTB_EXP(" This is the text of the first vector element"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 3.1424"); TEST_EVENT: INFO: Act: TTB_EXP(" Vector"); TEST_EVENT: INFO: Act: TTB_EXP(" id: 2"); TEST_EVENT: INFO: Act: TTB_EXP(" tolerance: 0.026"); TEST_EVENT: INFO: Act: TTB_EXP(" This is the text of the second vector element"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 3.1424"); TEST_EVENT: INFO: Act: TTB_EXP(" Vector"); TEST_EVENT: INFO: Act: TTB_EXP(" id: 3"); TEST_EVENT: INFO: Act: TTB_EXP(" tolerance: 1.357"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 6.2853"); TEST_EVENT: INFO: Act: TTB_EXP(" Group_B"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 1.2346"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 2.3581"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 3.1324"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 4.9877"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 5.2974"); TEST_EVENT: INFO: Act: TTB_EXP(" Group_C"); TEST_EVENT: INFO: Act: TTB_EXP(" Interior"); TEST_EVENT: INFO: Act: TTB_EXP(" Something"); TEST_EVENT: INFO: Act: TTB_EXP(" Some text"); ---- TEST_EVENT next section: "CheckNode - ignore complete subtree 'Group_A' " Furthermore set precision for 'x' to 1 TEST_EVENT: INFO: Act: TTB_EXP("MyContainer"); TEST_EVENT: INFO: Act: TTB_EXP(" Group_B"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 1.2"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 2.4"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 3.1"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 5.0"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 5.3"); TEST_EVENT: INFO: Act: TTB_EXP(" Group_C"); TEST_EVENT: INFO: Act: TTB_EXP(" Interior"); TEST_EVENT: INFO: Act: TTB_EXP(" Something"); TEST_EVENT: INFO: Act: TTB_EXP(" Some text"); ---- TEST_EVENT next section: "CheckSubNode with XPath - only Group_B (/MyContainer/Group_B)" TEST_EVENT: INFO: Act: TTB_EXP("Group_B"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 1.23456"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 2.3581"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 3.132437"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 4.987654"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 5.29741"); ---- TEST_EVENT next section: "CheckSubNode with XPath - first x element within Group_B (/MyContainer/Group_B/x)" TEST_EVENT: INFO: Act: TTB_EXP("x"); TEST_EVENT: INFO: Act: TTB_EXP(" 1.23456"); ---- TEST_EVENT next section: "CheckSubNode with XPath - third x element within Group_B (/MyContainer/Group_B/x[3])" TEST_EVENT: INFO: Act: TTB_EXP("x"); TEST_EVENT: INFO: Act: TTB_EXP(" 3.132437"); ---- TEST_EVENT next section: "CheckSubNode with XPath - second vector element of Group_A (/MyContainer/Group_A/Vector[2])" TEST_EVENT: INFO: Act: TTB_EXP("Vector"); TEST_EVENT: INFO: Act: TTB_EXP(" id: 2"); TEST_EVENT: INFO: Act: TTB_EXP(" date: 01.07.09"); TEST_EVENT: INFO: Act: TTB_EXP(" time: 09:15:12.234"); TEST_EVENT: INFO: Act: TTB_EXP(" tolerance: 0.0258"); TEST_EVENT: INFO: Act: TTB_EXP(" This is the text of the second vector element"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 3.14235"); ---- TEST_EVENT next section: "CheckSubNode with XPath - last vector element of Group_A (/MyContainer/Group_A/Vector[last()])" TEST_EVENT: INFO: Act: TTB_EXP("Vector"); TEST_EVENT: INFO: Act: TTB_EXP(" id: 3"); TEST_EVENT: INFO: Act: TTB_EXP(" tolerance: 1.357"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 6.28532"); ---- TEST_EVENT next section: "CheckSubNode with XPath - relative to subtree via SubNodeFromXPath (/MyContainer/Group_A, Vector[last())" TEST_EVENT: INFO: Act: TTB_EXP("Vector"); TEST_EVENT: INFO: Act: TTB_EXP(" id: 3"); TEST_EVENT: INFO: Act: TTB_EXP(" tolerance: 1.357"); TEST_EVENT: INFO: Act: TTB_EXP(" x"); TEST_EVENT: INFO: Act: TTB_EXP(" 6.28532"); ---- TEST_EVENT check section Leaving test case "TestCheckNode"; testing time: 47ms Entering test case "TestCompare" ---- TEST_EVENT next section: "Compare - with/without use of TestEvents)" Comparing two XML trees without differences (with TestEvents) TEST_EVENT: INFO: Act: TTB_EXP("XML-Compare: no differences found"); Comparing two XML trees without differences (without TestEvents) XML-Compare: no differences found Comparing two XML trees without differences - now suppressing OK message ---- TEST_EVENT next section: "Compare - detection of first difference" TEST_EVENT: INFO: Act: TTB_EXP("Difference detected"); TEST_EVENT: INFO: Act: TTB_EXP("A: time: 09:15:12.234 (line: 3 col: 34, path: //MyContainer/Group_A/Vector)"); TEST_EVENT: INFO: Act: TTB_EXP("B: time: 09:30:12.234 (line: 5 col: 34, path: //MyContainer/Group_A/Vector)"); ---- TEST_EVENT next section: "Compare - ignoring 'time'" TEST_EVENT: INFO: Act: TTB_EXP("Difference detected"); TEST_EVENT: INFO: Act: TTB_EXP("A: tolerance: 0.0258 (line: 7 col: 54, path: //MyContainer/Group_A/Vector)"); TEST_EVENT: INFO: Act: TTB_EXP("B: tolerance: 0.8258 (line: 9 col: 54, path: //MyContainer/Group_A/Vector)"); ---- TEST_EVENT next section: "Compare - using XPath to compare subtrees (/MyContainer/Group_B)" TEST_EVENT: INFO: Act: TTB_EXP("Difference detected"); TEST_EVENT: INFO: Act: TTB_EXP("A: 3.132437 (line: 18 col: 8, path: //MyContainer/Group_B/x/3.132437/)"); TEST_EVENT: INFO: Act: TTB_EXP("B: 12.132437 (line: 20 col: 8, path: //MyContainer/Group_B/x/12.132437/)"); For more test cases see also projects TestXmlCheckBasic,TestXmlCheckWithExtensionsForBoost ---- TEST_EVENT check section Leaving test case "TestCompare"; testing time: 47ms Entering test case "Cleanup" Test case Cleanup doesn't include any assertions Leaving test case "Cleanup" Leaving test suite "Master Test Suite" No errors detected