summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testing_and_debugging/gcd.py18
-rw-r--r--testing_and_debugging/lcmtestcases.txt2
-rw-r--r--testing_and_debugging/script.rst4
-rw-r--r--testing_and_debugging/slides.org4
-rw-r--r--testing_and_debugging/slides.tex4
5 files changed, 23 insertions, 9 deletions
diff --git a/testing_and_debugging/gcd.py b/testing_and_debugging/gcd.py
index 5bc9110..7cbb9a0 100644
--- a/testing_and_debugging/gcd.py
+++ b/testing_and_debugging/gcd.py
@@ -1,11 +1,25 @@
def gcd(a, b):
- if a%b==0:
+ if b==0:
return a
return gcd(b, a%b)
#if __name__ == '__main__':
# result = gcd(48, 64)
-# if result != 16:
+# if result!= 16:
# print "Test failed"
# print "Test Passed"
+
+
+#if __name__ == '__main__':
+# for line in open('testcases.txt'):
+# numbers = line.split()
+# x = int(numbers[0])
+# y = int(numbers[1])
+# result = int(numbers[2])
+# if gcd(x, y) != result:
+# print "Failed gcd test for", x, y
+# else:
+# print "Test passed" , result
+
+
diff --git a/testing_and_debugging/lcmtestcases.txt b/testing_and_debugging/lcmtestcases.txt
index 9097077..6bac05b 100644
--- a/testing_and_debugging/lcmtestcases.txt
+++ b/testing_and_debugging/lcmtestcases.txt
@@ -1,3 +1,3 @@
12 28 84
18 36 36
-4678 39763 79562
+4678 39763 2339
diff --git a/testing_and_debugging/script.rst b/testing_and_debugging/script.rst
index 28bc9f1..0ecc590 100644
--- a/testing_and_debugging/script.rst
+++ b/testing_and_debugging/script.rst
@@ -70,7 +70,7 @@ Open an editor and type the code shown on the slide and save it as gcd.py
{{{ Show slide, gcd function }}}
def gcd(a, b):
- if a % b == 0:
+ if b == 0:
return a
return gcd(b, a%b)
@@ -101,7 +101,7 @@ test case we know that the GCD is 16. So that is the expected output.
{{{ Show slide,Test for gcd.py }}}
def gcd(a, b):
- if a % b == 0:
+ if b == 0:
return a
return gcd(b, a%b)
diff --git a/testing_and_debugging/slides.org b/testing_and_debugging/slides.org
index 377d689..676664b 100644
--- a/testing_and_debugging/slides.org
+++ b/testing_and_debugging/slides.org
@@ -64,7 +64,7 @@ Spoken tutorial on -
- Create gcd.py file with:
#+begin_src python
def gcd(a, b):
- if a % b == 0:
+ if b == 0:
return b
return gcd(b, a%b)
#+end_src python
@@ -73,7 +73,7 @@ Spoken tutorial on -
- Edit gcd.py file
#+begin_src python
def gcd(a, b):
- if a % b == 0:
+ if b == 0:
return a
return gcd(b, a%b)
diff --git a/testing_and_debugging/slides.tex b/testing_and_debugging/slides.tex
index 6be2cde..d7a0dce 100644
--- a/testing_and_debugging/slides.tex
+++ b/testing_and_debugging/slides.tex
@@ -94,7 +94,7 @@ Spoken tutorial on -
\lstset{language=Python}
\begin{lstlisting}
def gcd(a, b):
- if a % b == 0:
+ if b == 0:
return b
return gcd(b, a%b)
\end{lstlisting}
@@ -110,7 +110,7 @@ def gcd(a, b):
\lstset{language=Python}
\begin{lstlisting}
def gcd(a, b):
- if a % b == 0:
+ if b == 0:
return a
return gcd(b, a%b)