Change glib test framework to minunit
This commit is contained in:
30
tests/add.c
Normal file
30
tests/add.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "minunit.h"
|
||||
#include "add.h"
|
||||
#include <stdlib.h> /* exit() */
|
||||
#include <stdio.h> /* perror(), printf(), fprintf() */
|
||||
|
||||
|
||||
int tests_run=0;
|
||||
|
||||
char * add_test() {
|
||||
mu_assert("add(1,2) must produce 3", add(1,2) == 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char * all_tests() {
|
||||
mu_run_test(add_test);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *result = all_tests();
|
||||
if (result) {
|
||||
printf("FAILURE\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("ALL TESTS PASSED");
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
8
tests/minunit.h
Normal file
8
tests/minunit.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef MINUNIT_H
|
||||
#define MINUNIT_H
|
||||
|
||||
extern int tests_run;
|
||||
#define mu_assert(message,test) do { if (!(test)) return message; } while (0)
|
||||
#define mu_run_test(test) do { char *result = test(); tests_run++; if (result) return result; } while (0)
|
||||
|
||||
#endif /* MINUNIT_H */
|
||||
Reference in New Issue
Block a user