diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ac70d78 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +exampleTest diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cedd730 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +exampleTest: picotest.o exampleTest.o + gcc -o exampleTest picotest.o exampleTest.o + +picotest.o: picotest.c picotest.h + gcc -c picotest.c + +exampleTest.o: exampleTest.c + gcc -c exampleTest.c + +clean: + rm *.o + rm exampleTest + +all: exampleTest \ No newline at end of file diff --git a/exampleTest.c b/exampleTest.c index 2e001d0..ba0263d 100644 --- a/exampleTest.c +++ b/exampleTest.c @@ -1,4 +1,4 @@ -#include "picotest.c" +#include "picotest.h" void *test_two_equals_one() { @@ -15,6 +15,7 @@ void *test_one_plus_one() int main(int ac, char **av) { + initializePicotest(); addTest(test_two_equals_one); addTest(test_one_plus_one); diff --git a/picotest.c b/picotest.c index 5a3a9b4..e18b5cb 100644 --- a/picotest.c +++ b/picotest.c @@ -1,22 +1,12 @@ -#include +#include "picotest.h" -#define RUN_TEST(test) do { char *output = test(); tests_run++; \ - if (output) return output; } while (0) -#define TEST_ASSERT(message, test) do { tests_run++; if (!(test)) { tests_failed++; printf("FAIL \t %s\n",message);} else { tests_passed++; printf("PASS \t %s\n",message);} } while (0) - -#define MAX_TESTS 99 - -extern int tests_run; -extern int tests_passed; -extern int tests_failed; - -void* tests[MAX_TESTS]; - -int tests_run = 0; -int tests_passed = 0; -int tests_failed = 0; - -int numTests = 0; +void initializePicotest() +{ + tests_run = 0; + tests_passed = 0; + tests_failed = 0; + numTests = 0; +} void addTest(void* test) { @@ -26,7 +16,7 @@ void addTest(void* test) } int executeTestSuite() -{ +{ printf("Test Results\n===============================================================================\n"); int i; diff --git a/picotest.h b/picotest.h new file mode 100644 index 0000000..03f2672 --- /dev/null +++ b/picotest.h @@ -0,0 +1,28 @@ +#ifndef PICOTEST_H +#define PICOTEST_H + +#include + +void addTest(void* test); +int executeTestSuite(); +void initializePicotest(); + +#define RUN_TEST(test) do { char *output = test(); tests_run++; \ + if (output) return output; } while (0) +#define TEST_ASSERT(message, test) do { tests_run++; if (!(test)) { tests_failed++; printf("FAIL \t %s\n",message);} else { tests_passed++; printf("PASS \t %s\n",message);} } while (0) + +#define MAX_TESTS 99 + +extern int tests_run; +extern int tests_passed; +extern int tests_failed; + +void* tests[MAX_TESTS]; + +int tests_run; +int tests_passed; +int tests_failed; + +int numTests; + +#endif \ No newline at end of file