def test_regression(self): from random import random as rnd from B import solve from time import time SIZE = 1000 # size of the regression (iterations) t1 = time() for _ in xrange(SIZE): # int(rnd() * (upper_bound - lower_bound) + lower_bound) for the parameter got = solve((int(rnd() * (1000 - 0)) + 0), (int(rnd() * (1000 - 1)) + 1)) self.assertEqual(got, -1) t2 = time() print "regressionOK : " + str(t2 - t1)
def test(input, ans): ans = str(ans) s_in = StringIO.StringIO(input) s_out = StringIO.StringIO() sys.stdin = s_in sys.stdout = s_out str(solve()) sys.stdin = sys.__stdin__ sys.stdout = sys.__stdout__ ans_tmp = s_out.getvalue().strip() if ans_tmp == ans: print "Correct %s -> %s" % (repr(input), repr(ans)) else: print "Wrong!! %s should %s not %s" % (repr(input), repr(ans), repr(ans_tmp))
def test_solve(self): self.assertEqual(solve(4, 9, [3, 3, 3, 3]), 4)
def test_solve(self): self.assertEqual(solve(4,[1,3,1,1]),2)
def test_solve(self): self.assertEqual(solve(30, -50), -1044)