#include <simgear/package/Catalog.hxx>
#include <simgear/package/Root.hxx>
+#include <simgear/package/Package.hxx>
#include <simgear/misc/sg_dir.hxx>
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;
}