Example #1
0
File: test.py Project: vbar/mueddi
    def test_foo(self):
        dawg = make_dawg(('foo', 'bar'))
        found = set(Iterator('baz', 1, dawg))
        self.assertEqual({'bar'}, found)

        found = set(Iterator('baz', 2, dawg))
        self.assertEqual({'bar'}, found)
Example #2
0
File: test.py Project: vbar/mueddi
    def test_tolerance(self):
        dictionary = ('meter', 'otter', 'potter')
        dawg = make_dawg(dictionary)
        found = set(Iterator('mutter', 1, dawg))
        self.assertEqual(set(), found)

        found = set(Iterator('mutter', 2, dawg))
        self.assertEqual(set(dictionary), found)
Example #3
0
File: test.py Project: vbar/mueddi
    def test_this(self):
        dictionary = ('this', 'that', 'other')
        dawg = make_dawg(dictionary)
        found = set(Iterator('the', 1, dawg))
        self.assertEqual(set(), found)

        found = set(Iterator('the', 2, dawg))
        self.assertEqual(set(dictionary), found)
Example #4
0
def test_independent(seen, n, dictionary, dawg, writer):
    external = set()
    for correct in dictionary:
        if distance(seen, correct) <= n:
            external.add(correct)

    row = [seen]
    internal = set()
    for found in Iterator(seen, n, dawg):
        row.append(found)
        internal.add(found)

    writer.writerow(row)

    if external != internal:
        raise Exception("results for %s differ" % seen)
Example #5
0
def test_repeat(seen, n, dawg, reader):
    row = next(reader)
    if not len(row):
        raise Exception("empty row")

    if row[0] != seen:
        raise Exception("result row start mismatch")

    i = 1
    for found in Iterator(seen, n, dawg):
        if row[i] != found:
            raise Exception("result row mismatch")

        i += 1

    if i != len(row):
        raise Exception("result row end mismatch")
Example #6
0
File: test.py Project: vbar/mueddi
 def test_initial_final(self):
     dawg = make_dawg(('', 'a'))
     found = set(Iterator('b', 1, dawg))
     self.assertEqual({'', 'a'}, found)
Example #7
0
File: test.py Project: vbar/mueddi
 def test_binary(self):
     dictionary = ('ababa', 'babab')
     dawg = make_dawg(dictionary)
     found = set(Iterator('abba', 3, dawg))
     self.assertEqual(set(dictionary), found)
Example #8
0
File: test.py Project: vbar/mueddi
 def test_long_head(self):
     found = set(Iterator('abtrtz', 1, make_dawg(('abtrbtz', ))))
     self.assertEqual({'abtrbtz'}, found)