-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathL03-slides.tex
149 lines (117 loc) · 3.46 KB
/
L03-slides.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
\documentclass{beamer}
\usetheme{Boadilla}
%\includeonlyframes{current}
\usepackage{times}
\usefonttheme{structurebold}
\usepackage{listings}
\usepackage{pgf}
\usepackage{tikz}
\usepackage{alltt}
\usepackage[normalem]{ulem}
\usetikzlibrary{arrows}
\usetikzlibrary{automata}
\usetikzlibrary{shapes}
\usepackage{amsmath,amssymb}
\usepackage{rotating}
\usepackage{ulem}
\usepackage{listings}
\usepackage{enumerate}
%\setbeamercovered{dynamic}
\setbeamertemplate{footline}[page number]{}
\setbeamertemplate{navigation symbols}{}
\usefonttheme{structurebold}
\title{Software Testing, Quality Assurance \& Maintenance---Lecture 3}
\author{Patrick Lam\\University of Waterloo}
\date{January 9, 2015}
\colorlet{redshaded}{red!25!bg}
\colorlet{shaded}{black!25!bg}
\colorlet{shadedshaded}{black!10!bg}
\colorlet{blackshaded}{black!40!bg}
\colorlet{darkred}{red!80!black}
\colorlet{darkblue}{blue!80!black}
\colorlet{darkgreen}{green!80!black}
\newcommand{\rot}[1]{\rotatebox{90}{\mbox{#1}}}
\newcommand{\gray}[1]{\mbox{#1}}
\newenvironment{changemargin}[1]{%
\begin{list}{}{%
\setlength{\topsep}{0pt}%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{1em}
\setlength{\listparindent}{\parindent}%
\setlength{\itemindent}{\parindent}%
\setlength{\parsep}{\parskip}%
}%
\item[]}{\end{list}}
\lstset{ %
language=Java,
basicstyle=\ttfamily,commentstyle=\scriptsize\itshape,showstringspaces=false,breaklines=true}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\frametitle{Plan}
\begin{changemargin}{2cm}
More examples on faults, errors and failures:
\begin{itemize}
\item numZero example (again);
\item assignment 1-like exercise for {\tt findLast};
\item testing line intersection algorithm
\end{itemize}
\end{changemargin}
\end{frame}
\begin{frame}
\begin{changemargin}{2em}
\begin{alltt}
public static numZero(int[] x) \{ \\
\quad int count = 0; \\
\quad for (int i = 1; i < x.length; i++) \{ \\
\qquad if (x[i] == 0) count++; \\
\quad \} \\
\quad return count;\\
\}
\end{alltt}
\end{changemargin}
\end{frame}
\begin{frame}[fragile]
\begin{lstlisting}
static public int findLast(int[] x, int y) {
for (int i = x.length - 1; i > 0 ; i--) {
if (x[i] == y) {
return i;
}
}
return -1;
}
@Test
public void testFindLast() {
int[] x = new int[] {2, 3, 5};
assertEquals(0, FindLast.findLast(x, 2));
}
\end{lstlisting}
\end{frame}
\begin{frame}
\frametitle{Exercise: Faults}
\begin{changemargin}{1cm}
Read the faulty program {\tt findLast}, which
includes a test case exhibiting a failure.\\[1em]
Answer the following questions:
\begin{enumerate}[(a)]
\item Identify the fault, and fix it.
\item If possible, identify a test case that does not execute the fault.
\item If possible, identify a test case that executes the fault, but does not result in an error state.
\item If possible, identify a test case that results in an error, but not a failure. (Hint: PC)
\item For the given test case, identify the first error state. Be sure to describe the complete state.
\end{enumerate}
\end{changemargin}
\end{frame}
\begin{frame}[fragile]
\begin{lstlisting}[language=Python]
class LineSegment:
def __init__(self, x1, x2):
self.x1 = x1; self.x2 = x2;
def intersect(a, b):
return (a.x1 < b.x2) & (a.x2 > b.x1);
\end{lstlisting}
\end{frame}
\end{document}