SlideShare a Scribd company logo
1 of 32
Download to read offline
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.
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;
}
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;
}
•
•
•
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;
}
int main(void){
test(sumMultiplesOf3and5(4),3);
test(sumMultiplesOf3and5(10),21);
return 0;
}
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;
}
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)

Trabajo de programacion
Trabajo de programacionTrabajo de programacion
Trabajo de programacion
 
Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3
 
Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2
 
Metodos Numericos
Metodos NumericosMetodos Numericos
Metodos Numericos
 
Program to remove Left factoring
Program to remove Left factoringProgram to remove Left factoring
Program to remove Left factoring
 
質數的判斷
質數的判斷質數的判斷
質數的判斷
 
(Meta 4) ejemplo calcular la mitad de un numero dev c++
(Meta 4) ejemplo calcular la mitad de un numero dev c++ (Meta 4) ejemplo calcular la mitad de un numero dev c++
(Meta 4) ejemplo calcular la mitad de un numero dev c++
 
Bubble sort
Bubble sortBubble sort
Bubble sort
 
B.f.s
B.f.sB.f.s
B.f.s
 
Nova microsoft word document
Nova microsoft word documentNova microsoft word document
Nova microsoft word document
 
Union
UnionUnion
Union
 
Ejercicios.
Ejercicios. Ejercicios.
Ejercicios.
 
program sederhana
program sederhanaprogram sederhana
program sederhana
 
Simulacion - Algoritmo congruencial cuadratico
Simulacion - Algoritmo congruencial cuadraticoSimulacion - Algoritmo congruencial cuadratico
Simulacion - Algoritmo congruencial cuadratico
 
Bancocic
BancocicBancocic
Bancocic
 
Daniel snake
Daniel snakeDaniel snake
Daniel snake
 
Prueba de montecarlo
Prueba de montecarloPrueba de montecarlo
Prueba de montecarlo
 
งาน#2
งาน#2งาน#2
งาน#2
 
Rafael vasquez
Rafael vasquezRafael vasquez
Rafael vasquez
 
Programming in C
Programming in CProgramming in C
Programming in C
 

Viewers also liked

3Com 3C18241
3Com 3C182413Com 3C18241
3Com 3C18241savomir
 
3Com 3CBLSF50-ME
3Com 3CBLSF50-ME3Com 3CBLSF50-ME
3Com 3CBLSF50-MEsavomir
 
3Com 10002220 REV AB
3Com 10002220 REV AB3Com 10002220 REV AB
3Com 10002220 REV ABsavomir
 
A donde van a parar
A donde van a pararA donde van a parar
A donde van a pararAna Varon
 
Builders in ahmedabad
Builders in ahmedabadBuilders in ahmedabad
Builders in ahmedabadPropChill
 
3Com 3CR17333A-91
3Com 3CR17333A-913Com 3CR17333A-91
3Com 3CR17333A-91savomir
 
3Com 1697-060-000-2.00
3Com 1697-060-000-2.003Com 1697-060-000-2.00
3Com 1697-060-000-2.00savomir
 
Proyecto de extraordinario informatica
Proyecto de extraordinario informaticaProyecto de extraordinario informatica
Proyecto de extraordinario informaticaLuis Guzmán
 

Viewers also liked (14)

3Com 3C18241
3Com 3C182413Com 3C18241
3Com 3C18241
 
Presentación dgcp mesicic
Presentación dgcp   mesicicPresentación dgcp   mesicic
Presentación dgcp mesicic
 
Magnus lönnbergprofile
Magnus lönnbergprofileMagnus lönnbergprofile
Magnus lönnbergprofile
 
Gender selection
Gender selectionGender selection
Gender selection
 
3Com 3CBLSF50-ME
3Com 3CBLSF50-ME3Com 3CBLSF50-ME
3Com 3CBLSF50-ME
 
3Com 10002220 REV AB
3Com 10002220 REV AB3Com 10002220 REV AB
3Com 10002220 REV AB
 
A donde van a parar
A donde van a pararA donde van a parar
A donde van a parar
 
Misión leonardo
Misión leonardoMisión leonardo
Misión leonardo
 
Untitled-10
Untitled-10Untitled-10
Untitled-10
 
Builders in ahmedabad
Builders in ahmedabadBuilders in ahmedabad
Builders in ahmedabad
 
3Com 3CR17333A-91
3Com 3CR17333A-913Com 3CR17333A-91
3Com 3CR17333A-91
 
3Com 1697-060-000-2.00
3Com 1697-060-000-2.003Com 1697-060-000-2.00
3Com 1697-060-000-2.00
 
Cuenta atras
Cuenta atrasCuenta atras
Cuenta atras
 
Proyecto de extraordinario informatica
Proyecto de extraordinario informaticaProyecto de extraordinario informatica
Proyecto de extraordinario informatica
 

Introduction to TDD in C