Esempio n. 1
0
	def test_reversed(self):
		var="abcde"
		test=lzstr(var)
		self.assertEqual(test.reversed, "edcba")

		var="maL wehttaM"
		test=lzstr(var)
		self.assertEqual(test.reversed, "Matthew Lam")
Esempio n. 2
0
	def test_rot13(self):
		var="AbCdE"
		test=lzstr(var)
		self.assertEqual(test.rot13,"NoPqR")

		var="1A2b3C"
		test= lzstr(var)
		self.assertEqual(test.rot13, "1N2o3P")
Esempio n. 3
0
	def test_toord(self):
		var= "abcde"
		test=lzstr(var)
		self.assertEqual(test.toord(),[97,98,99,100,101])


		var="feimaomiao"
		test=lzstr(var)
		self.assertEqual(test.toord(),[102, 101, 105, 109, 97, 111, 109, 105, 97, 111])

		var="Matthew Lam"
		test=lzstr(var)
		self.assertEqual(test.toord(),[77, 97, 116, 116, 104, 101, 119, 32, 76, 97, 109])
Esempio n. 4
0
	def test_remove(self):
		var="aabbccddeeddffeeccaba"
		test=lzstr(var)
		self.assertEqual(test.remove("aba"),"aabbccddeeddffeecc")
		self.assertEqual(test.remove("dee"),"aabbccdddffeeccaba")
		self.assertEqual(test.remove("^a.+a$"),"")
		self.assertEqual(test.remove("cde"), "aabbccddeeddffeeccaba")
Esempio n. 5
0
	def test_shuffle(self):
		random.seed(1234)
		var = "abcdefg"
		test= lzstr(var) 
		MSGSTRING=f"""\

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
For test lzstr.shuffle:
Before shuffle: {test}
After shuffle:  {test.shuffle()}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"""
		random.seed(1234)
		with open(OUTPUTFILE,"a") as file:
			print(MSGSTRING,file=file)
		self.assertTrue(all([i in var for i in test.shuffle()]))
Esempio n. 6
0
	def test_sum_of_ints(self):
		var = "阿塞12德法鼓山;1as2;ldkf4jqow12e4ijksf6ba4ksklkf"
		test=lzstr(var)
		# 1+2+1+2+4+1+2+4+6+4 = 27
		self.assertEqual(test.sum_of_ints(),27)
Esempio n. 7
0
	def test_join_all_ints(self):
		var = "basdf133.,a/s.dfqwer234ergs你好2qwr8euofidjkls"
		test= lzstr(var)
		self.assertEqual(test.join_all_ints(),13323428)
Esempio n. 8
0
	def test_fillwith(self):
		var = "111"
		test= lzstr(var)
		self.assertEqual(test.fill(5,"0"), "11100")
		self.assertEqual(test.fill(10,"a"),"111aaaaaaa")
Esempio n. 9
0
	def test_split_by(self):
		var="aaabbbcccdddeeefffggg"
		test=lzstr(var)
		self.assertEqual(test.split_by(3),["aaa","bbb","ccc","ddd","eee","fff","ggg"])
		self.assertEqual(test.split_by(6),["aaabbb","cccddd","eeefff","ggg"])
Esempio n. 10
0
	def test_sorted(self):
		var="igdedbfcha"
		test=lzstr(var)
		self.assertEqual(test.sorted,"abcddefghi")