]> git.mxchange.org Git - simgear.git/commitdiff
Packages: more unit-test coverage
authorJames Turner <zakalawe@mac.com>
Thu, 23 Apr 2015 21:05:50 +0000 (22:05 +0100)
committerJames Turner <zakalawe@mac.com>
Thu, 23 Apr 2015 21:05:50 +0000 (22:05 +0100)
simgear/package/CatalogTest.cxx
simgear/package/Package.cxx
simgear/package/Package.hxx
simgear/package/catalogTest1/catalog.xml

index e2b98aca74557fa254ce480795169f5d6f2ca7de..12dd42d7a72ca5b2a916a349c86dd74b323adb13 100644 (file)
@@ -46,7 +46,7 @@ int parseTest()
     COMPARE(cat->description(), "First test catalog");
 
 // check the packages too
-    COMPARE(cat->packages().size(), 2);
+    COMPARE(cat->packages().size(), 3);
 
     pkg::PackageRef p1 = cat->packages().front();
     COMPARE(p1->catalog(), cat.ptr());
@@ -66,6 +66,34 @@ int parseTest()
 
 
 // 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());
+
+
+    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;
index 323334b12e6fdcde9094c58fce27ba51a9208038..59480486848bd1f9527f238ffbfc71311a905ca4 100644 (file)
@@ -186,6 +186,11 @@ std::string Package::description() const
 {
     return getLocalisedProp("description");
 }
+
+string_set Package::tags() const
+{
+    return m_tags;
+}
     
 SGPropertyNode* Package::properties() const
 {
@@ -238,7 +243,7 @@ PackageList Package::dependencies() const
         
     // prefer local hangar package if possible, in case someone does something
     // silly with naming. Of course flightgear's aircraft search doesn't know
-    // about hanagrs, so names still need to be unique.
+    // about hangars, so names still need to be unique.
         PackageRef depPkg = m_catalog->getPackageById(depName);
         if (!depPkg) {   
             Root* rt = m_catalog->root();
index 50783063b9e5c3c775ad1f462f671774a240cb20..b73899200771a60747c1f5cccdc00ed69142c224 100644 (file)
@@ -112,7 +112,9 @@ public:
         { return m_catalog; }
     
     bool matches(const SGPropertyNode* aFilter) const;
-    
+
+    string_set tags() const;
+
     /**
      * download URLs for the package
      */
index 80e9983ffcb9afe074d23712993c9398c7db1eb7..79879f2e561ef58a39f6f10127c7d7e1f258a664 100644 (file)
@@ -7,27 +7,58 @@
     <version>8.1.*</version>
     <version>8.0.0</version>
     <version>8.2.0</version>
-    
+
     <package>
         <id>alpha</id>
         <name>Alpha package</name>
         <revision type="int">8</revision>
         <file-size-bytes type="int">1234567</file-size-bytes>
     </package>
-    
+
     <package>
         <id>c172p</id>
         <name>Cessna 172-P</name>
         <description>A plane made by Cessna</description>
         <revision type="int">42</revision>
         <file-size-bytes type="int">34567</file-size-bytes>
-        
-        <tags>
-            <tag>cessna</tag>
-            <tag>ga</tag>
-            <tag>piston</tag>
-            <tag>ifr</tag>
-        </tags>
+
+        <tag>cessna</tag>
+        <tag>ga</tag>
+        <tag>piston</tag>
+        <tag>ifr</tag>
+
+        <rating>
+          <FDM type="int">3</FDM>
+          <systems type="int">4</systems>
+          <model type="int">5</model>
+          <cockpit type="int">4</cockpit>
+        </rating>
+
+        <!-- local dependency -->
+        <depends>
+            <id>org.flightgear.test.catalog1.common-sounds</id>
+            <revision>10</revision>
+        </depends>
+
+        <variant>
+            <id>c172p-2d-panel</id>
+            <name>C172 with 2d panel only</name>
+        </variant>
+
+        <variant>
+            <id>c172p-floats</id>
+            <name>C172 with floats</name>
+        </variant>
+
+        <variant>
+            <id>c172p-skis</id>
+            <name>C172 with skis</name>
+        </variant>
+    </package>
+
+    <package>
+        <id>common-sounds</id>
+        <name>Common sound files for test catalog aircraft</name>
+        <revision>10</revision>
     </package>
 </PropertyList>
-    
\ No newline at end of file