Example #1
0
 def test_lz_factorise(self):
     """ LZ FACTORISATION: Test LZ factorisation """
     factors = factorise('ABCAB')
     expected = (('A', 0), ('B', 0), ('C', 0), (0, 2))
     assert_equal(factors, expected)
     factors = factorise('ABCABC')
     expected = (('A', 0), ('B', 0), ('C', 0), (0, 3))
     assert_equal(factors, expected)
     factors = factorise('ABCABCABC')
     expected = (('A', 0), ('B', 0), ('C', 0), (0, 6))
     assert_equal(factors, expected)
     factors = factorise('DCBABCCDCBA')
     expected = (('D', 0), ('C', 0), ('B', 0), ('A', 0), (2, 1), (1, 1), (1, 1), (0, 4))
     factors = factorise('ABCABCABCABC')
     expected = (('A', 0), ('B', 0), ('C', 0), (0, 9))
     assert_equal(factors, expected)
     factors = factorise('doddoddoddod')
     expected = (('d', 0), ('o', 0), (0, 1), (0, 9))
     assert_equal(factors, expected)
Example #2
0
 def test_lz_factorise(self):
     """ LZ FACTORISATION: Test LZ factorisation """
     factors = factorise('ABCAB')
     expected = (('A', 0), ('B', 0), ('C', 0), (0, 2))
     assert_equal(factors, expected)
     factors = factorise('ABCABC')
     expected = (('A', 0), ('B', 0), ('C', 0), (0, 3))
     assert_equal(factors, expected)
     factors = factorise('ABCABCABC')
     expected = (('A', 0), ('B', 0), ('C', 0), (0, 6))
     assert_equal(factors, expected)
     factors = factorise('DCBABCCDCBA')
     expected = (('D', 0), ('C', 0), ('B', 0), ('A', 0), (2, 1), (1, 1),
                 (1, 1), (0, 4))
     factors = factorise('ABCABCABCABC')
     expected = (('A', 0), ('B', 0), ('C', 0), (0, 9))
     assert_equal(factors, expected)
     factors = factorise('doddoddoddod')
     expected = (('d', 0), ('o', 0), (0, 1), (0, 9))
     assert_equal(factors, expected)
Example #3
0
 def test_lz_factorise_empty_string(self):
     """ LZ FACTORISATION: Raise expcetion when factorising empty string """
     factors = factorise("")
Example #4
0
 def test_lz_factorise_non_matching_ends(self):
     """ LZ FACTORISATION: Find LZ factorisation, where these repeats are not at the ends of the string """
     factors = factorise('AZZBZZC')
     expected = (('A', 0), ('Z', 0), (1, 1), ('B', 0), (1, 2), ('C', 0))
     assert_equal(factors, expected)
Example #5
0
 def test_lz_factorise_empty_string(self):
     """ LZ FACTORISATION: Raise expcetion when factorising empty string """
     factors = factorise("")
Example #6
0
 def test_lz_factorise_non_matching_ends(self):
     """ LZ FACTORISATION: Find LZ factorisation, where these repeats are not at the ends of the string """
     factors = factorise('AZZBZZC')
     expected = (('A', 0), ('Z', 0), (1, 1), ('B', 0), (1, 2), ('C', 0))
     assert_equal(factors, expected)