コード例 #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
ファイル: a8test.py プロジェクト: osccal/python-course
    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