def test_random_words(self): T, alphabet = 100, ["a", "b", "c", "d"] for _ in range(T): amount = random.randint(5, 50) input_words = [rand.random_word(random.randint(20, 300), alphabet) for\ _ in range(amount)] result = shortest_common_super_approx(input_words) self.check_superstring(result, input_words)
def test_many_abc_small_words(self): T, alphabet = 1000, ["a", "b", "c"] for _ in range(T): amount = random.randint(2, 4) input_words = [rand.random_word(random.randint(1, 4), alphabet)\ for _ in range(amount)] result = shortest_common_super_approx(input_words) self.check_superstring(result, input_words) self.check_length(result, input_words, alphabet)
def test_strict_bound_family(self): for k in range(2, 5): S = [ word for S_i in (get_si(i, k) for i in range(k)) for word in S_i ] V = [ "#" + "c" + ("b" * (i - 1)) + "c" + ("a" * (4**i - i - 1)) for i in range(1, k + 1) ] input_words = S + V result = shortest_common_super_approx(input_words) self.check_superstring(result, input_words) self.assertTrue(len(result) < 6 * k * 4**k)
def test_big_words_length(self): input_words = ["#" + "a" * 200, "#" + "b" * 300, "#" + "c" * 500] result = shortest_common_super_approx(input_words) self.check_superstring(result, input_words) self.assertTrue(len(result) < 2000)
def test_small(self): input_words = ["#abc", "#bca", "#cab", "#d"] result = shortest_common_super_approx(input_words) self.check_superstring(result, input_words) self.check_length(result, input_words, ["a", "b", "c", "d"])
def test_single_letters(self): input_words = ["#a", "#b", "#c", "#d", "#e", "#f", "#g"] result = shortest_common_super_approx(input_words) self.check_superstring(result, input_words)
def test_words_with_substrings(self): input_words = ["#abc", "#ab", "#c"] result = shortest_common_super_approx(input_words) self.check_superstring(result, input_words) self.check_length(result, input_words, ["a", "b", "c"])