示例#1
0
文件: test_lz.py 项目: Ichindar/dsts
 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)
示例#2
0
文件: test_lz.py 项目: Ichindar/dsts
 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)
示例#3
0
文件: test_lz.py 项目: Ichindar/dsts
 def test_lz_factorise_empty_string(self):
     """ LZ FACTORISATION: Raise expcetion when factorising empty string """
     factors = factorise("")
示例#4
0
文件: test_lz.py 项目: Ichindar/dsts
 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)
示例#5
0
文件: test_lz.py 项目: Ichindar/dsts
 def test_lz_factorise_empty_string(self):
     """ LZ FACTORISATION: Raise expcetion when factorising empty string """
     factors = factorise("")
示例#6
0
文件: test_lz.py 项目: Ichindar/dsts
 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)