summaryrefslogtreecommitdiff
path: root/tdd
diff options
context:
space:
mode:
authorMadhusudan.C.S2010-08-31 18:57:46 +0530
committerMadhusudan.C.S2010-08-31 18:57:46 +0530
commit3abe0eb562dce69d82f9b271f1d9588513546d1e (patch)
treefdb16d4efb6b3346b73ef6d018b6bb963258a45e /tdd
parent7ef1bb5e8f6e2ac7c897a5be1acb9efb684c1f7e (diff)
downloadsees-3abe0eb562dce69d82f9b271f1d9588513546d1e.tar.gz
sees-3abe0eb562dce69d82f9b271f1d9588513546d1e.tar.bz2
sees-3abe0eb562dce69d82f9b271f1d9588513546d1e.zip
Add the gcd.py sample file being used in the hand out.
Diffstat (limited to 'tdd')
-rw-r--r--tdd/gcd.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tdd/gcd.py b/tdd/gcd.py
new file mode 100644
index 0000000..0a3697b
--- /dev/null
+++ b/tdd/gcd.py
@@ -0,0 +1,17 @@
+def gcd(a, b):
+ while b != 0:
+ a, b = b, 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)
+
+ 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)
+
+ print "All tests passed!"