#include "propertyObject.hxx"
+#include <simgear/structure/exception.hxx>
+
using std::cout;
using std::cerr;
using std::endl;
using namespace simgear;
+
SGPropertyNode* testRoot = NULL;
bool testBasic()
return true;
}
+void testRelative()
+{
+ SGPropertyNode* n = testRoot->getNode("a");
+ assert(n);
+
+ PropertyObject<int> a1(n, "bar");
+ assert(a1 == 1234);
+
+ PropertyObject<int> a5(n, "some/child/path");
+ a5 = 4321;
+ assert(n->getIntValue("some/child/path") == 4321);
+
+ SGPropertyNode* m = testRoot->getNode("a/alice");
+ PropertyObject<std::string> a4(m);
+ assert(a4 == "aaaa");
+}
+
void testString()
{
PropertyObject<std::string> sp("a/alice");
}
}
+void testCreate()
+{
+ PropertyObject<bool> a = PropertyObject<bool>::create("a/lemon", true);
+ assert(a == true);
+ assert(testRoot->getBoolValue("a/lemon") == true);
+
+
+ PropertyObject<int> b(PropertyObject<int>::create("a/pear", 3142));
+ assert(b == 3142);
+
+ PropertyObject<std::string> c(PropertyObject<std::string>::create("a/lime", "fofofo"));
+ assert(c == "fofofo");
+
+// check overloads for string version
+ SGPropertyNode* n = testRoot->getNode("b", true);
+ PropertyObject<std::string> d(PropertyObject<std::string>::create(n, "grape", "xyz"));
+ assert(!strcmp(testRoot->getStringValue("b/grape"), "xyz"));
+
+
+}
+
int main(int argc, char* argv[])
{
testRoot = new SGPropertyNode();
return EXIT_FAILURE;
}
+ testRelative();
testReadMissing();
testString();
testAssignment();
testSTLContainer();
+ testCreate();
return EXIT_SUCCESS;
}