Beispiel #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')
Beispiel #2
0
	def test_str(self):
		rle = RLEString.RLEString("Hello")
		self.assertEqual(rle.__str__(), "Hello")
Beispiel #3
0
	def test_iscompressed_after_decompress_false(self):
		rle = RLEString.RLEString("Hello")
		rle.compress()
		rle.decompress()
		self.assertFalse(rle.iscompressed())
Beispiel #4
0
	def test_iscompressed_false(self):
		rle = RLEString.RLEString("Hello")
		self.assertFalse(rle.iscompressed())
Beispiel #5
0
	def test_iscompressed_true(self):
		rle = RLEString.RLEString("Hello")
		rle.compress()
		self.assertTrue(rle.iscompressed())
Beispiel #6
0
	def test_decompressed_correctly(self):
		rle = RLEString.RLEString("Hello")
		hello_decompressed = "Hello"
		rle.compress()
		rle.decompress()
		self.assertEqual(rle.__str__(), hello_decompressed)
Beispiel #7
0
	def test_already_decompressed(self):
		rle = RLEString.RLEString("Hello")
		#print(rle.compress())
		with self.assertRaises(Exception):
			rle.decompress()
Beispiel #8
0
 def test_decompresses_correctly(self):
     for string in ALPHABETIC:
         s = RLEString(string)
         s.compress()
         s.decompress()
         self.assertEqual(str(s), string)
Beispiel #9
0
 def test_compresses_correctly(self):
     for string, comp in zip(ALPHABETIC, COMPRESSED):
         s = RLEString(string)
         s.compress()
         self.assertEqual(str(s), comp)
Beispiel #10
0
 def test_cannot_decompress_when_uncompressed(self):
     s = RLEString('iamverycompressed')
     with self.assertRaises(Exception):
         s.decompress()
Beispiel #11
0
 def test_cannot_compress_twice(self):
     s = RLEString('hellllotherre')
     s.compress()
     with self.assertRaises(Exception):
         s.compress()
Beispiel #12
0
 def test_iscompressed_after_compress(self):
     s = RLEString('abcddd')
     s.compress()
     self.assertTrue(s.iscompressed())
Beispiel #13
0
 def test_raises_if_nonalphabetic(self):
     for s in NONALPHABETIC:
         with self.assertRaises(Exception):
             RLEString(s)
Beispiel #14
0
 def test_throws_exception_if_empty(self):
     with self.assertRaises(Exception):
         RLEString('')