示例#1
0
	def test_encode_decode(self):
		string = """Over hill, over dale, Thorough bush,
		thorough brier, Over park, over pale,
		Thorough flood, thorough fire!""".lower()
		string = "".join(string.split()) ## remove whitespace
		encoded_str = tutnese.encode(string)  ## encode the string & make lower
		## encode the string & rejoin ""
		encoded_str = "".join(tutnese.encode(string).split())
		decoded_str = tutnese.decode(encoded_str) ## decode the string again
		self.assertEqual(decoded_str, string)
示例#2
0
	def test_squa_1(self):
		"""
		test to check correct decode for edge case of
		bbbbb
		"""
		string = 'bbbbb'
		answer = 'squabsquabbub'
		encoded_str = tutnese.encode(string)
		self.assertEqual(answer, encoded_str)
示例#3
0
	def test_rand_gen_encode_decode(self):
		"""
		This test generates a random string and then tests
		that the encoded string returns the same value.
		"""
		string = self.generate_string()
		encoded_str = tutnese.encode(string) 
		decoded_str = tutnese.decode(encoded_str)
		string = tutnese.decode(encoded_str)
		self.assertEqual(decoded_str, string)
示例#4
0
	def test_encode_1(self):
		string_1 = """
		Over hill, over dale, Thorough bush, thorough brier, 
		Over park, over pale, Thorough flood, thorough fire!"""
		string_2 = """
		ovuverur hashisqual, ovuverur dudalule,
		tuthashorurougughash bubusushash,	tuthashorurougughash
		bubrurierur, ovuverur puparurkuck, ovuverur pupalule,
		tuthashorurougughash fufluloodud,	tuthashorurougughash fufirure!"""
		string_1 = "".join(string_1.split())
		string_2 = "".join(string_2.split())
		result = tutnese.encode(string_1)
		self.assertEqual(result, string_2)
示例#5
0
	def test_buncho_stuff(self):
		"""
		generates 100 strings of length 100 and puts them in a list
		for each string, encode, decode, and check if
		the decoded string is same as original string
		"""
		temp = list()
		for i in range(0,100):
			temp.append(self.generate_string())
		for element in temp:
			string = element
			encoded_str = tutnese.encode(string)
			decoded_str = tutnese.decode(encoded_str)
			string = tutnese.decode(encoded_str)
			self.assertEqual(decoded_str, string)
示例#6
0
	def test_squa_2(self):
		string = 'aaaaa'
		answer = 'aaaaa'
		encoded_str = tutnese.encode(string)
		self.assertEqual(answer, encoded_str)
示例#7
0
	def test_encode_2(self):
		string_1 = "my name is brian"
		string_2 = "mumyub nunamume isus bubrurianun"
		result = tutnese.encode(string_1)
		self.assertEqual(result, string_2)
示例#8
0
 def testEncode(self):
     self.assertEqual(encode(self.string), self.encode)
 def test_encode_pdf_string(self):
     input_string = "Over hill, over dale, Thorough bush, thorough brier, Over park, over pale, Thorough flood, thorough fire!"
     solution_string = "ovuverur hashisqual, ovuverur dudalule, tuthashorurougughash bubusushash, tuthashorurougughash bubrurierur, ovuverur puparurkuck, ovuverur pupalule, tuthashorurougughash fufluloodud, tuthashorurougughash fufirure!"
     self.assertEqual(solution_string, encode(input_string))
 def test_encode_spaces(self):
     self.assertEqual("\t  ", encode("\t  "))
 def test_encode_empty(self):
     self.assertEqual(encode(""), "")
 def test_encode_invalid(self):
     with self.assertRaises(ValueError):
         encode("Invalid String |")