示例#1
0
 def test_isDeompressed(self):
     ''' 
         Test if the compress function updates iscompressed() properly
     '''
     for test in succeed_tests:
         rle = RLEString(test)
         rle.compress()
         rle.decompress()
         result = rle.iscompressed()
         self.assertFalse(result)
示例#2
0
 def test_decompress(self):
     ''' 
         Test if the decompress function decompresses properly
     '''
     for test in succeed_tests:
         rle = RLEString(test)
         rle.compress()
         rle.decompress()
         result = rle.__str__()
         self.assertEqual(result, test)
示例#3
0
 def test_doubleDecompress(self):
     ''' 
         Test if the compress function handles double-decompress
     '''
     for test in succeed_tests:
         with self.assertRaises(Exception):
             rle = RLEString(test)
             rle.compress()
             rle.decompress()
             rle.decompress()
示例#4
0
    tests = [
        "aaa", "a", "TTTTTeeeesssst", "AAAABBBBCCCCDEFGHIIIIIIJJ",
        "There are more than 3 non-alphabeticals in this one when we count spaces!",
        "abcdefghjiklmno", ""
    ]

    for t in tests:
        try:
            rle = RLEString(t)

            print("Original: %s" % (rle))
            rle.compress()
            compressed = rle.__str__()
            if compressed == t:
                raise Exception("Original string equals compressed!")
                pass

            print("Compressed: %s" % (rle))

            rle.decompress()
            if not rle.__str__() == t:
                raise Exception(
                    "Compression error, expected original after decompress!")

            rle.decompress()
            rle.compress()
            rle.compress()

        except Exception as e:
            print(e)
            pass