コード例 #1
0
ファイル: test_tutnese.py プロジェクト: brianwu02/csc473
	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)
コード例 #2
0
ファイル: test_tutnese.py プロジェクト: brianwu02/csc473
	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)
コード例 #3
0
ファイル: test_tutnese.py プロジェクト: brianwu02/csc473
	def test_decode_1(self):
		string_1 = "my name is brian"
		string_2 = "mumyub nunamume isus bubrurianun"
		string_1 = "".join(string_1.split())
		string_2 = "".join(string_2.split())
		result = tutnese.decode(string_2)
		self.assertEqual(result, string_1)
コード例 #4
0
 def testDecode(self):
     self.assertEqual(
         decode(
             'ovuverur hashisqual, ovuverur dudalule, tuthashorurougughash bubusushash, tuthashorurougughash bubrurierur, ovuverur puparurkuck, ovuverur pupalule, tuthashorurougughash fufluloodud, tuthashorurougughash fufirure!'
         ),
         'over hill, over dale, thorough bush, thorough brier, over park, over pale, thorough flood, thorough fire!'
     )
コード例 #5
0
ファイル: test_tutnese.py プロジェクト: brianwu02/csc473
	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)
コード例 #6
0
ファイル: test_tutnese.py プロジェクト: brianwu02/csc473
	def test_decode_2(self):
		string_1 = """
		Over hill, over dale, Thorough bush,
		thorough brier, Over park, over pale,
		Thorough flood, thorough fire!""".lower()
		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.decode(string_2)
		self.assertEqual(result, string_1)
コード例 #7
0
 def test_decode_pdf_string(self):
     input_string = "ovuverur hashisqual, ovuverur dudalule, tuthashorurougughash bubusushash, tuthashorurougughash bubrurierur, ovuverur puparurkuck, ovuverur pupalule, tuthashorurougughash fufluloodud, tuthashorurougughash fufirure!"
     solution_string = "Over hill, over dale, Thorough bush, thorough brier, Over park, over pale, Thorough flood, thorough fire!".lower()
     self.assertEqual(solution_string, decode(input_string))
コード例 #8
0
 def test_decode_spaces(self):
     self.assertEqual("\t  ", decode("\t  "))
コード例 #9
0
 def test_decode_empty(self):
     self.assertEqual(decode(""), "")
コード例 #10
0
 def test_decode_invalid(self):
     with self.assertRaises(ValueError):
         decode("Invalid String |")