예제 #1
0
 def test_to_string_leaf(self):
     n = BinaryNode(BinaryNodeRef(), "k", ValueRef(address=999), BinaryNodeRef(), 1)
     pickled = BinaryNodeRef.referent_to_string(n)
     d = pickle.loads(pickled)
     eq_(d["left"], 0)
     eq_(d["key"], "k")
     eq_(d["value"], 999)
     eq_(d["right"], 0)
예제 #2
0
 def test_to_string_leaf(self):
     n = BinaryNode(BinaryNodeRef(), 'k', ValueRef(address=999),
                    BinaryNodeRef(), 1)
     pickled = BinaryNodeRef.referent_to_string(n)
     d = pickle.loads(pickled)
     eq_(d['left'], 0)
     eq_(d['key'], 'k')
     eq_(d['value'], 999)
     eq_(d['right'], 0)
예제 #3
0
 def test_to_string_nonleaf(self):
     left_ref = BinaryNodeRef(address=123)
     right_ref = BinaryNodeRef(address=321)
     n = BinaryNode(left_ref, 'k', ValueRef(address=999), right_ref, 3)
     pickled = BinaryNodeRef.referent_to_string(n)
     d = pickle.loads(pickled)
     eq_(d['left'], 123)
     eq_(d['key'], 'k')
     eq_(d['value'], 999)
     eq_(d['right'], 321)
예제 #4
0
 def test_to_string_nonleaf(self):
     left_ref = BinaryNodeRef(address=123)
     right_ref = BinaryNodeRef(address=321)
     n = BinaryNode(left_ref, "k", ValueRef(address=999), right_ref, 3)
     pickled = BinaryNodeRef.referent_to_string(n)
     d = pickle.loads(pickled)
     eq_(d["left"], 123)
     eq_(d["key"], "k")
     eq_(d["value"], 999)
     eq_(d["right"], 321)
예제 #5
0
 def test_to_string_leaf(self):
     n = BinaryNode(BinaryNodeRef(), 'k', ValueRef(address=999), BinaryNodeRef(), 1)
     pickled = BinaryNodeRef.referent_to_string(n)
     d = pickle.loads(pickled)
     eq_(d['left'], 0)
     eq_(d['key'], 'k')
     eq_(d['value'], 999)
     eq_(d['right'], 0)
예제 #6
0
 def test_to_string_nonleaf(self):
     left_ref = BinaryNodeRef(address=123)
     right_ref = BinaryNodeRef(address=321)
     n = BinaryNode(left_ref, 'k', ValueRef(address=999), right_ref, 3)
     pickled = BinaryNodeRef.referent_to_string(n)
     d = pickle.loads(pickled)
     eq_(d['left'], 123)
     eq_(d['key'], 'k')
     eq_(d['value'], 999)
     eq_(d['right'], 321)