// -*- c -*- // // $Id: node_unit.moc,v 1.9 2001/02/10 20:07:41 kmacleod Exp $ // #include @namespace a_uri some:uri main() { id err; int ii; id jj1 = (id)0xdeadbeef; id jj2 = (id)0xabcd1000; id a_value = (id)0xdeadbeef; id node = Node__new(NULL, 0); id new_node, keys; int failed = 0; printf ("1..8\n"); ok(@node.get_stored(MOC_FALSE) == MOC_NIL, 1); @node.put_stored((id)0xdeadbeef, (id)0xabcd0123); ok(@node.get_stored((id)0xdeadbeef) == (id)0xabcd0123, 2); for (ii = 0; ii < 25; ii ++) { @node.put_stored(jj1, jj2); jj1 ++; jj2 ++; } jj1 = (id)0xdeadbeef; jj2 = (id)0xabcd1000; for (ii = 0; ii < 25; ii ++) { failed |= @node.get_stored(jj1) != jj2; jj1 ++; jj2 ++; } ok(!failed, 3); @node.a_uri:a_name = a_value; ok(@node.a_uri:a_name == a_value, 4); ok(@node.a_uri:b_name != a_value, 5); node = Node__new(NULL, 0); @node.foo = MOC_TRUE; @node.a_uri:bar = MOC_FALSE; keys = @node.keys(); ok(Int_i(@keys.length()) == 2, 6); ok(( ((List_ati_i(keys, 0) == Symbol__new_s("foo")) && (List_ati_i(keys, 1) == Key__new_ss("some:uri", "bar"))) || ((List_ati_i(keys, 0) == Key__new_ss("some:uri", "bar")) && (List_ati_i(keys, 1) == Symbol__new_s("foo"))) ), 7); Try { @node.unknown_method(); ok(0, 8); } Catch(err) { id detail = @err.detail; ok(@detail.equals(@"node type NodeType does not understand selector _unknown_method") == MOC_TRUE, 8); } return 0; }