test-autotools-static/tests/add.c

37 lines
710 B
C
Raw Normal View History

2015-06-23 19:17:24 +02:00
#include "minunit.h"
#include "add.h"
#include <stdlib.h> /* exit() */
#include <stdio.h> /* perror(), printf(), fprintf() */
int tests_run=0;
2015-06-23 21:43:51 +02:00
char * test_add_fail() {
mu_assert("add(1,2) must produce 4", add(1,2) == 4);
return 0;
}
char * test_add_sucess() {
mu_assert("add(1,2) must produce 3", add(1,2) == 3);
2015-06-23 19:17:24 +02:00
return 0;
}
char * all_tests() {
2015-06-23 21:43:51 +02:00
printf("1..2\n");
mu_run_test("test_add_fail", test_add_fail);
mu_run_test("test_add_sucess", test_add_sucess);
2015-06-23 19:17:24 +02:00
return 0;
}
int main(int argc, char *argv[])
{
char *result = all_tests();
if (result) {
2015-06-23 21:43:51 +02:00
printf("# FAILURE\n");
2015-06-23 19:17:24 +02:00
}
2015-06-23 21:43:51 +02:00
printf("#ALL TESTS PASSED\n");
2015-06-23 19:17:24 +02:00
2015-06-23 21:43:51 +02:00
return 0; /* tap tests report failures via stdout not exit code */
2015-06-23 19:17:24 +02:00
}