X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fpackage%2FCatalogTest.cxx;h=12dd42d7a72ca5b2a916a349c86dd74b323adb13;hb=a3f1bb546fec72b07f11f69934e6894696fea57a;hp=ef7da7a652249fe77d4dbfb60ff5d1f663e0b73b;hpb=b7fbb7956535ea89cdf6f9d1a77fc8799efd93b0;p=simgear.git diff --git a/simgear/package/CatalogTest.cxx b/simgear/package/CatalogTest.cxx index ef7da7a6..12dd42d7 100644 --- a/simgear/package/CatalogTest.cxx +++ b/simgear/package/CatalogTest.cxx @@ -26,6 +26,7 @@ #include #include +#include #include @@ -45,9 +46,56 @@ int parseTest() COMPARE(cat->description(), "First test catalog"); // check the packages too + COMPARE(cat->packages().size(), 3); + + pkg::PackageRef p1 = cat->packages().front(); + COMPARE(p1->catalog(), cat.ptr()); + + COMPARE(p1->id(), "alpha"); + COMPARE(p1->qualifiedId(), "org.flightgear.test.catalog1.alpha"); + COMPARE(p1->name(), "Alpha package"); + COMPARE(p1->revision(), 8); + COMPARE(p1->fileSizeBytes(), 1234567); + + + pkg::PackageRef p2 = cat->getPackageById("c172p"); + VERIFY(p2.valid()); + COMPARE(p2->qualifiedId(), "org.flightgear.test.catalog1.c172p"); + COMPARE(p2->description(), "A plane made by Cessna"); + + + +// test filtering / searching too + string_set tags(p2->tags()); + COMPARE(tags.size(), 4); + VERIFY(tags.find("ifr") != tags.end()); + VERIFY(tags.find("cessna") != tags.end()); + VERIFY(tags.find("jet") == tags.end()); - delete root; + SGPropertyNode_ptr queryA(new SGPropertyNode); + queryA->setStringValue("tag", "ifr"); + VERIFY(p2->matches(queryA.ptr())); + + SGPropertyNode_ptr queryB(new SGPropertyNode); + queryB->setStringValue("name", "ces"); + VERIFY(p2->matches(queryB.ptr())); + + SGPropertyNode_ptr queryC(new SGPropertyNode); + queryC->setStringValue("name", "foo"); + VERIFY(!p2->matches(queryC.ptr())); + + SGPropertyNode_ptr queryD(new SGPropertyNode); + queryD->setIntValue("rating-FDM", 3); + VERIFY(p2->matches(queryD.ptr())); + + SGPropertyNode_ptr queryE(new SGPropertyNode); + queryE->setIntValue("rating-model", 5); + queryE->setStringValue("description", "cessna"); + VERIFY(p2->matches(queryE.ptr())); + + + delete root; return EXIT_SUCCESS; }