Example #1
0
 def test_can_compress_after_decompress(self):
     s = RLEString('iwillbecompressed')
     s.compress()
     s.decompress()
     try:
         s.compress()
     except Exception:
         self.fail('Unable to compress after decompress')
Example #2
0
	def test_str(self):
		rle = RLEString.RLEString("Hello")
		self.assertEqual(rle.__str__(), "Hello")
Example #3
0
	def test_iscompressed_after_decompress_false(self):
		rle = RLEString.RLEString("Hello")
		rle.compress()
		rle.decompress()
		self.assertFalse(rle.iscompressed())
Example #4
0
	def test_iscompressed_false(self):
		rle = RLEString.RLEString("Hello")
		self.assertFalse(rle.iscompressed())
Example #5
0
	def test_iscompressed_true(self):
		rle = RLEString.RLEString("Hello")
		rle.compress()
		self.assertTrue(rle.iscompressed())
Example #6
0
	def test_decompressed_correctly(self):
		rle = RLEString.RLEString("Hello")
		hello_decompressed = "Hello"
		rle.compress()
		rle.decompress()
		self.assertEqual(rle.__str__(), hello_decompressed)
Example #7
0
	def test_already_decompressed(self):
		rle = RLEString.RLEString("Hello")
		#print(rle.compress())
		with self.assertRaises(Exception):
			rle.decompress()
Example #8
0
 def test_decompresses_correctly(self):
     for string in ALPHABETIC:
         s = RLEString(string)
         s.compress()
         s.decompress()
         self.assertEqual(str(s), string)
Example #9
0
 def test_compresses_correctly(self):
     for string, comp in zip(ALPHABETIC, COMPRESSED):
         s = RLEString(string)
         s.compress()
         self.assertEqual(str(s), comp)
Example #10
0
 def test_cannot_decompress_when_uncompressed(self):
     s = RLEString('iamverycompressed')
     with self.assertRaises(Exception):
         s.decompress()
Example #11
0
 def test_cannot_compress_twice(self):
     s = RLEString('hellllotherre')
     s.compress()
     with self.assertRaises(Exception):
         s.compress()
Example #12
0
 def test_iscompressed_after_compress(self):
     s = RLEString('abcddd')
     s.compress()
     self.assertTrue(s.iscompressed())
Example #13
0
 def test_raises_if_nonalphabetic(self):
     for s in NONALPHABETIC:
         with self.assertRaises(Exception):
             RLEString(s)
Example #14
0
 def test_throws_exception_if_empty(self):
     with self.assertRaises(Exception):
         RLEString('')