SlideShare a Scribd company logo
Introduction to TDD in C
Introduction to TDD in C
Introduction to TDD in C
1.
1.
2.
1.
2.
3.
1.
2.
3.
4.
1.
2.
3.
4.
5.
1.
2.
3.
4.
5.
1.
2.
3.
4.
5.
Introduction to TDD in C
Introduction to TDD in C
Introduction to TDD in C
Introduction to TDD in C
Introduction to TDD in C
int sum_of_multiples(int border){
int sum = 0;
// calculate something
return sum;
}
void test(int output,int expected){
if(output == expected)
printf("Test:t successn");
else
printf("Test:t failn");
}
int main(void){
test(sum_of_multiples(4),3);
return 0;
}
Introduction to TDD in C
int sum_of_multiples(int border){
int sum = 0;
// calculate something
for(int i=1; i<border; i++){
if(i%3==0) sum += i;
}
return sum;
}
Introduction to TDD in C
•
•
•
int sumMultiplesOf3and5(int border){
int sum = 0;
// calculate something
for(int i=1; i<border; i++){
if(i%3==0) sum += i;
}
return sum;
}
int sumMultiplesOf3and5(int border){
int sum = 0;
for(int i=1; i<border; i++){
if(i%3==0) sum += i;
}
return sum;
}
Introduction to TDD in C
int main(void){
test(sumMultiplesOf3and5(4),3);
test(sumMultiplesOf3and5(10),21);
return 0;
}
Introduction to TDD in C
int sumMultiplesOf3and5(int border){
int sum = 0;
for(int i=1; i<border; i++){
if(i%3==0 || i%5==0) sum += i;
}
return sum;
}
Introduction to TDD in C
int main(void){
test(sumMultiplesOf3and5(4),3);
test(sumMultiplesOf3and5(10),21);
test(sumMultiplesOf3and5(100),2318);
return 0;
}
Introduction to TDD in C
Introduction to TDD in C

More Related Content

What's hot (20)

PDF
Bcsl 033 data and file structures lab s4-3
Dr. Loganathan R
 
PDF
Bcsl 033 data and file structures lab s1-2
Dr. Loganathan R
 
DOCX
Metodos Numericos
andres felipe chamorro
 
DOCX
Program to remove Left factoring
Shraddha Patel
 
DOCX
質數的判斷
Hui-Shih Leng
 
DOCX
(Meta 4) ejemplo calcular la mitad de un numero dev c++
Eli Diaz
 
PDF
Bubble sort
Hitesh Kumar
 
DOCX
B.f.s
MDFERDOUSAHMED
 
DOCX
Nova microsoft word document
Saša Ličina
 
PDF
Union
archana chitte
 
DOC
Ejercicios.
Jose Dani
 
DOCX
program sederhana
muhammadalfin03
 
DOCX
Simulacion - Algoritmo congruencial cuadratico
José Antonio Sandoval Acosta
 
TXT
Bancocic
edgarflores28
 
DOCX
Daniel snake
Tefaa Salazar
 
DOCX
Prueba de montecarlo
Gonzalo Negrete Montaño
 
PDF
งาน#2
Bam'nunnaput Sabangban
 
DOCX
Rafael vasquez
Rafael Vasquez
 
PDF
Programming in C
Vineet Kumar Saini
 
Bcsl 033 data and file structures lab s4-3
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-2
Dr. Loganathan R
 
Metodos Numericos
andres felipe chamorro
 
Program to remove Left factoring
Shraddha Patel
 
質數的判斷
Hui-Shih Leng
 
(Meta 4) ejemplo calcular la mitad de un numero dev c++
Eli Diaz
 
Bubble sort
Hitesh Kumar
 
Nova microsoft word document
Saša Ličina
 
Ejercicios.
Jose Dani
 
program sederhana
muhammadalfin03
 
Simulacion - Algoritmo congruencial cuadratico
José Antonio Sandoval Acosta
 
Bancocic
edgarflores28
 
Daniel snake
Tefaa Salazar
 
Prueba de montecarlo
Gonzalo Negrete Montaño
 
Rafael vasquez
Rafael Vasquez
 
Programming in C
Vineet Kumar Saini
 

Viewers also liked (14)

PPTX
3Com 3C18241
savomir
 
PPTX
Presentación dgcp mesicic
Manu Gonzalez Caballero
 
PDF
Magnus lönnbergprofile
Magnus Lönnberg
 
PPTX
Gender selection
genderselectionaustralia
 
PPTX
3Com 3CBLSF50-ME
savomir
 
PPTX
3Com 10002220 REV AB
savomir
 
PPTX
A donde van a parar
Ana Varon
 
PPTX
Misión leonardo
leonardoramirez7271
 
PPT
Untitled-10
olenaterekha
 
PPTX
Builders in ahmedabad
PropChill
 
PPTX
3Com 3CR17333A-91
savomir
 
PPTX
3Com 1697-060-000-2.00
savomir
 
PPTX
Cuenta atras
segundociclocm
 
DOCX
Proyecto de extraordinario informatica
Luis Guzmán
 
3Com 3C18241
savomir
 
Presentación dgcp mesicic
Manu Gonzalez Caballero
 
Magnus lönnbergprofile
Magnus Lönnberg
 
Gender selection
genderselectionaustralia
 
3Com 3CBLSF50-ME
savomir
 
3Com 10002220 REV AB
savomir
 
A donde van a parar
Ana Varon
 
Misión leonardo
leonardoramirez7271
 
Untitled-10
olenaterekha
 
Builders in ahmedabad
PropChill
 
3Com 3CR17333A-91
savomir
 
3Com 1697-060-000-2.00
savomir
 
Cuenta atras
segundociclocm
 
Proyecto de extraordinario informatica
Luis Guzmán
 
Ad

Introduction to TDD in C