summaryrefslogtreecommitdiff
path: root/tdd
diff options
context:
space:
mode:
authorMadhusudan.C.S2010-08-31 20:14:18 +0530
committerMadhusudan.C.S2010-08-31 20:14:18 +0530
commit837f3192a27b8367ff55d98865029947e7db9a50 (patch)
tree9ede02f1677d710c5c0b5ed2514db34b46856426 /tdd
parent0ad5bac2a7c61a46feeac4b1bddc4cb4ba66e8b0 (diff)
downloadsees-837f3192a27b8367ff55d98865029947e7db9a50.tar.gz
sees-837f3192a27b8367ff55d98865029947e7db9a50.tar.bz2
sees-837f3192a27b8367ff55d98865029947e7db9a50.zip
Manipulated the python gcd script to accommodate new way of testing.
Diffstat (limited to 'tdd')
-rw-r--r--tdd/gcd.py17
1 files changed, 9 insertions, 8 deletions
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!"