Skip to content

Commit

Permalink
Fixing some general debauchery
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscowdery committed Sep 16, 2011
1 parent 7b6a72b commit c76c71d
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@

exampleTest
14 changes: 14 additions & 0 deletions 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
3 changes: 2 additions & 1 deletion exampleTest.c
@@ -1,4 +1,4 @@
#include "picotest.c"
#include "picotest.h"

void *test_two_equals_one()
{
Expand All @@ -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);

Expand Down
28 changes: 9 additions & 19 deletions picotest.c
@@ -1,22 +1,12 @@
#include <stdio.h>
#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)
{
Expand All @@ -26,7 +16,7 @@ void addTest(void* test)
}

int executeTestSuite()
{
{
printf("Test Results\n===============================================================================\n");

int i;
Expand Down
28 changes: 28 additions & 0 deletions picotest.h
@@ -0,0 +1,28 @@
#ifndef PICOTEST_H
#define PICOTEST_H

#include <stdio.h>

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

0 comments on commit c76c71d

Please sign in to comment.