// // $Id: test_orchardcc.cc,v 1.1 2001/01/22 14:15:18 kmacleod Exp $ // #include #include "orchard.h" #define itr "urn:to-be-determined" main() { Orchard *node1 = Orchard::new_node("Node"); Orchard *node2 = Orchard::new_node("Node"); Orchard *node3 = Orchard::new_node("Node"); OrchardIndex *index = Orchard::index("foo"); Orchard *node; node1->put(index, node1); node = node1->get(index); ok(node == node1, 1); node1->put("urn:fu", "foo", node2); node = node1->get("urn:fu", "foo"); ok(node == node2, 2); node1->put("foo", node3); node = node1->get("foo"); ok(node == node3, 3); char *str_value; node1->put(index, "blip"); str_value = node1->get(index)->asString(); ok(strcmp(str_value, "blip") == 0, 4); node1->put("urn:fu", "foo", "zap"); str_value = node1->get("urn:fu", "foo")->asString(); ok(strcmp(str_value, "zap") == 0, 5); node1->put("foo", "blargle"); str_value = node1->get("foo")->asString(); ok(strcmp(str_value, "blargle") == 0, 6); // XXX need to test exceptions // str = node1->get("bar"); int int_value; node1->put(index, 7); int_value = node1->get(index)->asInt(); ok(7 == int_value, 7); node1->put("urn:fu", "foo", 13); int_value = node1->get("urn:fu", "foo")->asInt(); ok(13 == int_value, 8); node1->put("foo", 42); int_value = node1->get("foo")->asInt(); ok(42 == int_value, 9); // XXX need to test exceptions // str = node1->get("bar"); Orchard *list = node1->call("keys"); int_value = list->call("length")->asInt(); ok(2 == int_value, 10); // try { // str = node1->getString("foo"); // ok(0, 3); // } catch (const char *message) { // ok(1, 3); // } catch (...) { // printf("hrmm\n"); // } }