From 837f3192a27b8367ff55d98865029947e7db9a50 Mon Sep 17 00:00:00 2001 From: Madhusudan.C.S Date: Tue, 31 Aug 2010 20:14:18 +0530 Subject: Manipulated the python gcd script to accommodate new way of testing. --- tdd/gcd.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'tdd') diff --git a/tdd/gcd.py b/tdd/gcd.py index 0a3697b..454a719 100644 --- a/tdd/gcd.py +++ b/tdd/gcd.py @@ -4,14 +4,15 @@ def gcd(a, b): return a if __name__ == '__main__': - tc1 = gcd(48, 64) - if tc1 != 16: - print "Test failed for the case a=48 and b=64. Expected 16. Obtained %d instead." % tc1 - exit(1) + for line in open('gcd_testcases.dat'): + values = line.split(', ') + a = int(values[0]) + b = int(values[1]) + g = int(values[2]) - tc2 = gcd(44, 19) - if tc2 != 1: - print "Test failed for the case a=44 and b=19. Expected 1. Obtained %d instead." % tc2 - exit(1) + tc = gcd(a, b) + if tc != g: + print "Test failed for the case a=%d and b=%d. Expected %d. Obtained %d instead." % (a, b, g, tc) + exit(1) print "All tests passed!" -- cgit