def test_solve(self): self.assertTrue(solve(1,100,50)) self.assertFalse(solve(10,10,100)) self.assertTrue(solve(1,100,50)) self.assertTrue(solve(100,3,50)) self.assertFalse(solve(1,98,50)) self.assertTrue(solve(2,50,50)) self.assertTrue(solve(2,50,49)) self.assertTrue(solve(2,50,51)) self.assertFalse(solve(2,50,0))
def test_regression(self): from random import random as rnd from A 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) 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() 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_easy(): assert len(solve(2, 2)) == 2 assert len(solve(2, 3)) == 3 assert len(solve(3, 3)) == 3 assert len(solve(3, 4)) == 4 assert len(solve(4, 4)) == 4 assert len(solve(5, 6)) == 6 assert len(solve(5, 7)) == 6 assert len(solve(5, 8)) == 7 assert len(solve(5, 9)) == 7 assert len(solve(5, 10)) == 8 assert len(solve(10, 5)) == 8
def test_solve(self): self.assertEqual(solve(3,3),10)
def test_solve(self): self.assertEqual(solve(3, 3, 2), 5)
def test_solve(self): self.assertEqual(solve('8080'),'Good')