]> git.mxchange.org Git - simgear.git/blobdiff - simgear/package/CatalogTest.cxx
HTTP request cancellation
[simgear.git] / simgear / package / CatalogTest.cxx
index ef7da7a652249fe77d4dbfb60ff5d1f663e0b73b..12dd42d7a72ca5b2a916a349c86dd74b323adb13 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <simgear/package/Catalog.hxx>
 #include <simgear/package/Root.hxx>
+#include <simgear/package/Package.hxx>
 
 #include <simgear/misc/sg_dir.hxx>
 
@@ -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;
 }