summaryrefslogtreecommitdiff
path: root/TDD/getting_started_with_tdd/tdd1.tex
diff options
context:
space:
mode:
authorJovina2012-08-03 11:35:54 +0530
committerJovina2012-08-03 11:35:54 +0530
commita9c09136b785a5769d7b927c22f416f1964016fe (patch)
treea4d4b9b7b142bbe5051485d69640e17e2f32b16e /TDD/getting_started_with_tdd/tdd1.tex
parent18d8394b05bc6cc52cd1a54a59a22163b5147c34 (diff)
parentf71e9c3a7f4407dcd1ade3858c9a3a07028ce716 (diff)
downloadsdes-stscripts-a9c09136b785a5769d7b927c22f416f1964016fe.tar.gz
sdes-stscripts-a9c09136b785a5769d7b927c22f416f1964016fe.tar.bz2
sdes-stscripts-a9c09136b785a5769d7b927c22f416f1964016fe.zip
Merge branch 'master' of http://github.com/FOSSEE/sdes-stscripts
Diffstat (limited to 'TDD/getting_started_with_tdd/tdd1.tex')
-rw-r--r--TDD/getting_started_with_tdd/tdd1.tex69
1 files changed, 62 insertions, 7 deletions
diff --git a/TDD/getting_started_with_tdd/tdd1.tex b/TDD/getting_started_with_tdd/tdd1.tex
index f056ce5..042c5c4 100644
--- a/TDD/getting_started_with_tdd/tdd1.tex
+++ b/TDD/getting_started_with_tdd/tdd1.tex
@@ -254,7 +254,7 @@ def fibonacci(n):
\begin{itemize}
-\item Undestand the basic steps involved in Test driven development.
+\item Understand the basic steps involved in Test driven development.
\item Design a TDD approach for a given \texttt{fibonacci} function.
\end{itemize}
@@ -267,20 +267,75 @@ def fibonacci(n):
\begin{enumerate}
-\item ?
+\item Design a TDD approach for a \texttt{factorial} function.
\vspace{8pt}
-\item ?
+\item Design a TDD approach for an \texttt{armstrong} function.
\end{enumerate}
\end{frame}
-\begin{frame}
+
+\begin{frame}[fragile]
\frametitle{Solutions}
\label{sec-10}
+\begin{enumerate}
+\vspace{15pt}
+\item
+{\tiny
+\begin{lstlisting}
+def factorial(n):
+ if n < 0 :
+ return None;
+ if n == 1:
+ return 1
+ else:
+ return n * factorial (n - 1)
+if __name__ == '__main__':
+ f = factorial(3)
+ if f != 6 :
+ print 'Test Failed...'
+ exit (1)
+ f = factorial(-5)
+ if f != None :
+ print 'Test Failed...'
+ exit (1)
+ print 'All tests passed...'
+\end{lstlisting}
+}
+\end{enumerate}
+\end{frame}
-
+\begin{frame}[fragile]
+\frametitle{Solutions}
+\label{sec-10}
\begin{enumerate}
-\item
\vspace{15pt}
-\item
+\item
+{\tiny
+\begin{lstlisting}
+def armstrong(n):
+ sum = 0
+ temp = 0
+ remainder = 0
+ temp = n
+ while temp > 0 :
+ remainder = temp % 10
+ sum = sum + remainder * remainder * remainder
+ temp = temp / 10
+ if n == sum:
+ return True
+ else:
+ return False
+if __name__ == '__main__':
+ is_armstrong = armstrong(0)
+ if is_armstrong != True:
+ print "this is not armstrong"
+ exit(1)
+ is_armstrong = armstrong(371)
+ if is_armstrong == True:
+ print "this is armstrong"
+ exit(1)
+ print 'All tests passed...'
+\end{lstlisting}
+}
\end{enumerate}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%