# HG changeset patch # User Madhusudan.C.S # Date 1283261266 -19800 # Node ID a6a442d1bbd94a1e4ef69e99f3c4fbe6e64c06af # Parent 4e7b98636b5885be38f4dce5a63aab23bda78821 Add the gcd.py sample file being used in the hand out. diff -r 4e7b98636b58 -r a6a442d1bbd9 tdd/gcd.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tdd/gcd.py Tue Aug 31 18:57:46 2010 +0530 @@ -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!"