示例#1
0
    def test_accept_feature_node(self):
        self.fn.accept(self.tv)
        dfi = FeatureNodeIteratorDepthFirst(self.fn)
        f = dfi.next()
        nodes = []
        while f:
            nodes.append(f)
            f = dfi.next()
        self.assertEqual(nodes[1].get_type(), "bar")

        self.assertRaises(GTError, self.fn.accept, self.etv)
        self.cn.accept(self.etv)
        self.sn.accept(self.etv)
        self.rn.accept(self.etv)
    def test_accept_feature_node(self):
        self.fn.accept(self.tv)
        dfi = FeatureNodeIteratorDepthFirst(self.fn)
        f = dfi.next()
        nodes = []
        while f:
            nodes.append(f)
            f = dfi.next()
        self.assertEqual(nodes[1].get_type(), "bar")

        self.assertRaises(GTError, self.fn.accept, self.etv)
        self.cn.accept(self.etv)
        self.sn.accept(self.etv)
        self.rn.accept(self.etv)
    def test_fni(self):
        fn = self.fn
        fni = FeatureNodeIteratorDepthFirst(fn)
        num_features = 0
        tfn = fni.next()
        while tfn:
            tfn = fni.next()
            num_features += 1
        self.assertEqual(num_features, 2)

        fn3 = FeatureNode.create_new("test", "type3", 250, 300, "+")
        fn.add_child(fn3)
        fni = FeatureNodeIteratorDepthFirst(fn)

        num_features = 0
        tfn = fni.next()
        while tfn:
            num_features += 1
            tfn = fni.next()
        self.assertEqual(num_features, 3)
示例#4
0
    def test_fni(self):
        fn = self.fn
        fni = FeatureNodeIteratorDepthFirst(fn)
        num_features = 0
        tfn = fni.next()
        while tfn:
            tfn = fni.next()
            num_features += 1
        self.assertEqual(num_features, 2)

        fn3 = FeatureNode.create_new("test", "type3", 250, 300, "+")
        fn.add_child(fn3)
        fni = FeatureNodeIteratorDepthFirst(fn)

        num_features = 0
        tfn = fni.next()
        while tfn:
            num_features += 1
            tfn = fni.next()
        self.assertEqual(num_features, 3)