Exemple #1
0
    def test_insert(self):
        """Correctly inserts a new key into the trie"""
        t = CompressedTrie(self.data)
        t.insert("babc", "9")
        self.assertTrue("9" in t.find("babc"))

        exp1 = {
            "1": ["6", "2", "0", "5"],
            "9": ["7"],
            "3": [],
            "4": [],
            "8": []
        }
        exp2 = {
            "1": ["6", "2", "0", "5"],
            "9": [],
            "3": ["7"],
            "4": [],
            "8": []
        }
        exp3 = {
            "1": ["6", "2", "0", "5"],
            "9": [],
            "3": [],
            "4": [],
            "8": ["7"]
        }
        self.assertTrue(t.prefix_map in (exp1, exp2, exp3))
Exemple #2
0
    def test_insert(self):
        """Correctly inserts a new key into the trie"""
        t = CompressedTrie(self.data)
        t.insert("babc", "9")
        self.assertTrue("9" in t.find("babc"))

        exp1 = {"1": ["6", "2", "0", "5"],
                "9": ["7"],
                "3": [],
                "4": [],
                "8": []}
        exp2 = {"1": ["6", "2", "0", "5"],
                "9": [],
                "3": ["7"],
                "4": [],
                "8": []}
        exp3 = {"1": ["6", "2", "0", "5"],
                "9": [],
                "3": [],
                "4": [],
                "8": ["7"]}
        self.assertTrue(t.prefix_map in (exp1, exp2, exp3))