]> git.mxchange.org Git - simgear.git/blobdiff - simgear/props/props_test.cxx
cppbind: automatic conversion of SGReferenced derived pointers.
[simgear.git] / simgear / props / props_test.cxx
index f8299263a1252f58753a99e25139eee9385243db..debf79d78debb7a09ce1797ee32a726d5a058370 100644 (file)
@@ -11,9 +11,6 @@
 
 #include <iostream>
 
-// working around MSVC weirdness with props.hxx and SGMathFwd
-#include <simgear/math/SGMath.hxx>
-
 #include "props.hxx"
 #include "props_io.hxx"
 
@@ -22,7 +19,7 @@ using std::cerr;
 using std::endl;
 
 
-\f
+
 ////////////////////////////////////////////////////////////////////////
 // Sample object.
 ////////////////////////////////////////////////////////////////////////
@@ -41,7 +38,7 @@ private:
 };
 
 
-\f
+
 ////////////////////////////////////////////////////////////////////////
 // Sample function.
 ////////////////////////////////////////////////////////////////////////
@@ -51,7 +48,7 @@ static int get100 () { return 100; }
 static double getNum (int index) { return 1.0 / index; }
 
 
-\f
+
 ////////////////////////////////////////////////////////////////////////
 // Show a value.
 ////////////////////////////////////////////////////////////////////////
@@ -67,7 +64,7 @@ show_values (const SGPropertyNode * node)
 }
 
 
-\f
+
 ////////////////////////////////////////////////////////////////////////
 // Test individual values.
 ////////////////////////////////////////////////////////////////////////
@@ -273,7 +270,7 @@ test_value ()
 }
 
 
-\f
+
 ////////////////////////////////////////////////////////////////////////
 // Check property nodes.
 ////////////////////////////////////////////////////////////////////////
@@ -327,7 +324,7 @@ test_property_nodes ()
 
   cout << "Testing addition of a totally empty node" << endl;
   if (root.getNode("/a/b/c", true) == 0)
-    cerr << "** failed to create /a/b/c" << endl;
+    cerr << "** FAILED to create /a/b/c" << endl;
   dump_node(&root);
   cout << endl;
 }
@@ -341,14 +338,49 @@ void test_addChild()
 
   SGPropertyNode *test = root.getChild("test", 0, true);
   SGPropertyNode *n = test->getNode("foo", true);
+
+  cout << "Testing appending initial child node" << endl;
+  test = root.addChild("child", 0, true);
+  if (test == 0)
+    cerr << "** FAILED to append initial child node" << endl;
+  if (root.getNode("child", 0, false) != test)
+      cerr << "** FAILED to create initial child node at expected index #0" << endl;
+
   n->getChild("child", 1, true)->setIntValue(1);
   n->getChild("child", 2, true)->setIntValue(2);
-  n->getChild("child", 4, true)->setIntValue(2);
+  n->getChild("child", 4, true)->setIntValue(4);
   dump_node(&root);
 
   SGPropertyNode *ch = n->addChild("child");
-  ch->setIntValue(3);
+  ch->setIntValue(5);
+  if (n->getChild("child", 5, false) != ch)
+      cerr << "** FAILED to create child node at expected index #5" << endl;
   cerr << endl << "ADDED: " << ch->getPath() << endl << endl;
+
+  cout << "Testing appending child node at first empty index (Skipping 0)" << endl;
+  ch = n->addChild("child", 1, false);
+  ch->setIntValue(3);
+  if (n->getChild("child", 3, false) != ch)
+      cerr << "** FAILED to create child node at expected index #3" << endl;
+
+  cout << "Testing appending child node at first empty index" << endl;
+  ch = n->addChild("child", 0, false);
+  ch->setIntValue(0);
+  if (n->getChild("child", 0, false) != ch)
+      cerr << "** FAILED to create child node at expected index #0" << endl;
+
+  cout << "Testing appending child node" << endl;
+  ch = n->addChild("first", 0, false);
+  if (ch == 0)
+      cerr << "** Failed to add child node" << endl;
+  else
+      ch->setStringValue("append first");
+  if (n->getChild("first", 0, false) != ch)
+      cerr << "** FAILED to append child node with expected index #0" << endl;
+  cerr << "ADDED: " << ch->getPath() << endl;
+  if (root.getNode("test/foo/first", false) != ch)
+      cerr << "** FAILED to append child node at expected path 'test/foo/first'" << endl;
+
   dump_node(&root);
 }