@@ -71,12 +71,6 @@ class TestLibrary : public TestFixture {
7171 TEST_CASE (loadLibErrors);
7272 }
7373
74- static Library::Error readLibrary (Library& library, const char * xmldata) {
75- tinyxml2::XMLDocument doc;
76- doc.Parse (xmldata);
77- return library.load (doc);
78- }
79-
8074 void isCompliantValidationExpression () const {
8175 ASSERT_EQUALS (true , Library::isCompliantValidationExpression (" -1" ));
8276 ASSERT_EQUALS (true , Library::isCompliantValidationExpression (" 1" ));
@@ -103,7 +97,7 @@ class TestLibrary : public TestFixture {
10397 // Reading an empty library file is considered to be OK
10498 const char xmldata[] = " <?xml version=\" 1.0\" ?>\n <def/>" ;
10599 Library library;
106- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
100+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
107101 ASSERT (library.functions .empty ());
108102 }
109103
@@ -121,7 +115,7 @@ class TestLibrary : public TestFixture {
121115 tokenList.front ()->next ()->astOperand1 (tokenList.front ());
122116
123117 Library library;
124- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
118+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
125119 ASSERT_EQUALS (library.functions .size (), 1U );
126120 ASSERT (library.functions .at (" foo" ).argumentChecks .empty ());
127121 ASSERT (library.isnotnoreturn (tokenList.front ()));
@@ -136,7 +130,7 @@ class TestLibrary : public TestFixture {
136130 " </def>" ;
137131
138132 Library library;
139- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
133+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
140134 {
141135 TokenList tokenList (nullptr );
142136 std::istringstream istr (" fred.foo(123);" ); // <- wrong scope, not library function
@@ -168,7 +162,7 @@ class TestLibrary : public TestFixture {
168162 tokenList.createAst ();
169163
170164 Library library;
171- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
165+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
172166 ASSERT (library.isNotLibraryFunction (tokenList.front ()));
173167 }
174168
@@ -182,7 +176,7 @@ class TestLibrary : public TestFixture {
182176 " </def>" ;
183177
184178 Library library;
185- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
179+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
186180
187181 {
188182 TokenList tokenList (nullptr );
@@ -237,7 +231,7 @@ class TestLibrary : public TestFixture {
237231 tokenList.front ()->next ()->varId (1 );
238232
239233 Library library;
240- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
234+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
241235 ASSERT (library.isNotLibraryFunction (tokenList.front ()->next ()));
242236 }
243237
@@ -254,7 +248,7 @@ class TestLibrary : public TestFixture {
254248 " </def>" ;
255249
256250 Library library;
257- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
251+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
258252 ASSERT_EQUALS (0 , library.functions [" foo" ].argumentChecks [1 ].notuninit );
259253 ASSERT_EQUALS (true , library.functions [" foo" ].argumentChecks [2 ].notnull );
260254 ASSERT_EQUALS (true , library.functions [" foo" ].argumentChecks [3 ].formatstr );
@@ -273,7 +267,7 @@ class TestLibrary : public TestFixture {
273267 " </def>" ;
274268
275269 Library library;
276- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
270+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
277271 ASSERT_EQUALS (0 , library.functions [" foo" ].argumentChecks [-1 ].notuninit );
278272 }
279273
@@ -287,7 +281,7 @@ class TestLibrary : public TestFixture {
287281 " </def>" ;
288282
289283 Library library;
290- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
284+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
291285 ASSERT_EQUALS (0 , library.functions [" foo" ].argumentChecks [-1 ].notuninit );
292286
293287 TokenList tokenList (nullptr );
@@ -313,7 +307,7 @@ class TestLibrary : public TestFixture {
313307 " </def>" ;
314308
315309 Library library;
316- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
310+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
317311
318312 TokenList tokenList (nullptr );
319313 std::istringstream istr (" foo(a,b,c,d);" );
@@ -345,7 +339,7 @@ class TestLibrary : public TestFixture {
345339 " </def>" ;
346340
347341 Library library;
348- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
342+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
349343
350344 TokenList tokenList (nullptr );
351345 std::istringstream istr (" foo(a,b,c,d,e,f,g,h,i,j,k);" );
@@ -487,7 +481,7 @@ class TestLibrary : public TestFixture {
487481 " </def>" ;
488482
489483 Library library;
490- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
484+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
491485
492486 TokenList tokenList (nullptr );
493487 std::istringstream istr (" foo(a,b,c,d,e);" );
@@ -546,7 +540,7 @@ class TestLibrary : public TestFixture {
546540 " </def>" ;
547541
548542 Library library;
549- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
543+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
550544 ASSERT_EQUALS (library.functions .size (), 2U );
551545 ASSERT (library.functions .at (" Foo::foo" ).argumentChecks .empty ());
552546 ASSERT (library.functions .at (" bar" ).argumentChecks .empty ());
@@ -575,7 +569,7 @@ class TestLibrary : public TestFixture {
575569 " </def>" ;
576570
577571 Library library;
578- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
572+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
579573 ASSERT_EQUALS (library.functions .size (), 1U );
580574
581575 {
@@ -602,7 +596,7 @@ class TestLibrary : public TestFixture {
602596 " </def>" ;
603597
604598 Library library;
605- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
599+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
606600
607601 {
608602 Tokenizer tokenizer (&settings, nullptr );
@@ -631,7 +625,7 @@ class TestLibrary : public TestFixture {
631625 " </def>" ;
632626
633627 Library library;
634- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
628+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
635629
636630 TokenList tokenList (nullptr );
637631 std::istringstream istr (" a(); b();" );
@@ -665,7 +659,7 @@ class TestLibrary : public TestFixture {
665659 " </def>" ;
666660
667661 Library library;
668- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
662+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
669663 ASSERT (library.functions .empty ());
670664
671665 ASSERT (Library::ismemory (library.getAllocFuncInfo (" CreateX" )));
@@ -708,7 +702,7 @@ class TestLibrary : public TestFixture {
708702 " </def>" ;
709703
710704 Library library;
711- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
705+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
712706 ASSERT (library.functions .empty ());
713707
714708 const Library::AllocFunc* af = library.getAllocFuncInfo (" CreateX" );
@@ -727,7 +721,7 @@ class TestLibrary : public TestFixture {
727721 " </def>" ;
728722
729723 Library library;
730- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
724+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
731725 ASSERT (library.functions .empty ());
732726
733727 ASSERT (Library::isresource (library.allocId (" CreateX" )));
@@ -744,7 +738,7 @@ class TestLibrary : public TestFixture {
744738 " <podtype name=\" s16\" sign=\" s\" size=\" 2\" />\n "
745739 " </def>" ;
746740 Library library;
747- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
741+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
748742 // s8
749743 {
750744 const struct Library ::PodType * const type = library.podtype (" s8" );
@@ -822,7 +816,7 @@ class TestLibrary : public TestFixture {
822816 " </def>" ;
823817
824818 Library library;
825- ASSERT_EQUALS ( true , Library::ErrorCode::OK == ( readLibrary ( library, xmldata)). errorcode );
819+ ASSERT ( library. loadxmldata (xmldata, sizeof ( xmldata)));
826820
827821 Library::Container& A = library.containers [" A" ];
828822 Library::Container& B = library.containers [" B" ];
@@ -937,16 +931,14 @@ class TestLibrary : public TestFixture {
937931 " <def>\n "
938932 " </def>" ;
939933 Library library;
940- const Library::Error err = readLibrary (library, xmldata);
941- ASSERT_EQUALS (true , err.errorcode == Library::ErrorCode::OK);
934+ ASSERT (library.loadxmldata (xmldata, sizeof (xmldata)));
942935 }
943936 {
944937 const char xmldata[] = " <?xml version=\" 1.0\" ?>\n "
945938 " <def format=\" 1\" >\n "
946939 " </def>" ;
947940 Library library;
948- const Library::Error err = readLibrary (library, xmldata);
949- ASSERT_EQUALS (true , err.errorcode == Library::ErrorCode::OK);
941+ ASSERT (library.loadxmldata (xmldata, sizeof (xmldata)));
950942 }
951943 {
952944 const char xmldata[] = " <?xml version=\" 1.0\" ?>\n "
@@ -958,6 +950,12 @@ class TestLibrary : public TestFixture {
958950 }
959951 }
960952
953+ static Library::Error readLibrary (Library& library, const char * xmldata) {
954+ tinyxml2::XMLDocument doc;
955+ doc.Parse (xmldata); // TODO: check result
956+ return library.load (doc);
957+ }
958+
961959 void loadLibError (const char xmldata[], Library::ErrorCode errorcode, const char * file, unsigned line) const {
962960 Library library;
963961 assertEquals (file, line, true , errorcode == readLibrary (library, xmldata).errorcode );
0 commit comments