Hey, how about some determenistic tests? Wouldn't that be real great?

This commit is contained in:
enkore 2013-03-08 16:00:42 +01:00
parent 9084661a5d
commit 37b69fd158
2 changed files with 34 additions and 13 deletions

View File

@ -27,7 +27,3 @@ def basic_test_generator():
yield factory(path, "{status}", status)
yield factory(path, "{consumption:.3f}", consumption)
yield factory(path, "{remaining_hm}", remaining)
#suite = unittest.TestLoader().loadTestsFromName(__name__)
#unittest.TextTestRunner(verbosity=2).run(suite)

View File

@ -21,17 +21,45 @@ def lchop_factory(prefix, string):
return test
def lchop_test_generator():
nmin = 5
nmax = 20
for n in range(nmin, nmax):
prefix = get_random_string(n)
string = get_random_string(2*nmax-n)
cases = [
('\x0b,S0I', "=t5Bk+\x0b'_;duq=9"),
('H1@\x0b_\t', '<&9<;Q(0L";^$7'),
('NWV#B0u', '~Q_wx5"$W\x0b[(T'),
('by=uHfZ>', 'AdytjC5-OUR\\'),
('/FD|^6=m3', 'l0:%ibW7*}S'),
('!.LsV90/$\x0b', 'nD}L&4]MGC'),
('S0zOIvbm:~L', 'jJ\\UGOMY<'),
("'aZ@,AA\x0b;Dmm", 'ZD +9}f;'),
('Ae;=SoHD(1VPJ', 'x\r)du,+'),
('ANDT \t>tZ1Iy9}', 'wpz%F`'),
('|w?>bv,t# BkGeE', '07mZR'),
('1MSN\x0c\r}Tu8r3uCe)', '\\I6-'),
('0;-!MVW4+\rz]J3@SQ', 'lvG'),
('Zi\x0b^5E?}a\\KJ(,O4n(', '8:'),
('I-X[~2sQigGLA_~ZD%G', '#'),
(':xio!', 'v=ApOu\t_,}'),
('%bM%W\n', '7$wZ]gaL!U/%'),
('~\x0bILq>+', '[4}LhQ1zz1m?D&'),
('+"a)\x0c:4Q', '\niNQ+GY8+)UtQ\r#M'),
('R3PHi/[S*', 'J7fV19X(c^^J(9BAY+'),
('%Z?=m|3Wtr', 'O7K%GpQRJR%y}wIDq~H\\'),
('wyR0V*y^+D)', '>tsX)@%=u[83/hf0j?+xXV'),
('4}joZKr?j$u)', '\r\x0cje4QAha\\Y2]V\n`5[.TG~$0'),
('at%Y)%g5.*vKJ', 'MnucPcE!h;gkhAdI*`Jv$%dafJ'),
('XKH\\n\'gf4@"6`-', '#~:Nt[^9wtE.4\\@<i|tWiu|p7:uw'),
('mLV!q;:\n\nk5u\x0cD>', "9)#qPuEF-A@ -DTE\r= (KgM\\h'i$XU"),
("<|(h|P9Wz9d9'u,M", '7d-A\nY{}5"\' !*gHHh`x0!B2Ox?yeKb\x0b'),
('bV?:f\x0b#HDhuwSvys3', ";\r,L![\x0cU7@ne@'?[*&V<dap]+Tq[n1!|PE"),
('T\r~bGV^@JC?P@Pa66.', "9,q>VI,[}pHM\nB65@LfE16VJPw=r'zU\x0bzWj@"),
('^|j7N!mV0o(?*1>p?dy', '\\ZdA&:\t\x0b:8\t|7.Kl,oHw-\x0cS\nwZlND~uC@le`Sm'),
]
for prefix, string in cases:
yield lchop_factory(prefix, prefix+string)
yield lchop_factory(prefix, string)
yield lchop_factory(string, string)
yield lchop_factory(string, prefix)
yield lchop_factory("", string)
yield lchop_factory(prefix, "")
def partition_factory(iterable, limit, assrt):
def test():
@ -52,6 +80,3 @@ def partition_test_generator():
for iterable, limit, assrt in cases:
yield partition_factory(iterable, limit, assrt)
suite = unittest.TestLoader().loadTestsFromName(__name__)
unittest.TextTestRunner(verbosity=2).run(suite)