]> git.mdlowis.com Git - projs/atf.git/commitdiff
Updated README and removed unnecessary macro from atf.h
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 22 Feb 2017 01:48:02 +0000 (20:48 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 22 Feb 2017 01:48:02 +0000 (20:48 -0500)
README.md
atf.h

index 87012243768c58249edf9e9b43b5a8e4baf4773c..6cf9234ff3495e424d8af79b5f8133f59fc4b3a7 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,4 +1,60 @@
-atf
-===
+# Aardvark Test Framework
+
+A minimal unit testing framework for C distributed as a single-header library.
+
+# License
+
+This program is distributed under the terms of the ISC license as described in
+[LICENSE.md](LICENSE.md)
+
+# Installation
+
+Simply copy [atf.h](atf.h) to a suitable include path for the desired project.
+
+# Macro API
+
+The framework is controlled through an extremely minimal of C preprocessor 
+macros. The macros are used to define test suites, define tests within suites,
+and to perform actual conditional checks as part of the test. Below is a 
+comprehensive list of the macros provided and their function.
+
+```C
+TEST_SUITE(name) {}         // Define a new test suite with the given name
+TEST(desc) {}               // Define a new test with the given description
+CHECK(cond)                 // Check that condition is true and mark test is failed if false
+IGNORE(msg)                 // Mark a test as ignored with a message and skip its execution
+EXPECT_EXIT {}              // Setup test to expect the mock exit function to be called
+CHECK_EXITCODE(code)        // Checks that the mock exit function received the given exit code
+RUN_TEST_SUITE(name)        // Runs the specified test suite
+RUN_EXTERN_TEST_SUITE(name) // Runs the specified test suite, the suite is externed first
+INCLUDE_DEFS                // Instructs the header to also include definitions of the API functions on include
+```
+
+# Example Usage
+
+```C
+#define INCLUDE_DEFS
+#include <atf.h>
+
+TEST_SUITE(ExampleTests) {
+    TEST(Check that 1 < 2) {
+        CHECK(1 < 2);
+    }
+    
+    TEST(Check that exit is called with 42) {
+        EXPECT_EXIT { exit(42); }
+        CHECK_EXITCODE(42);
+    }
+    
+    TEST(This test is ignored) {
+        IGNORE("Practice ignore");
+    }
+}
+
+int main(int argc, char** argv) {
+    atf_init(argc, argv);
+    RUN_TEST_SUITE(ExampleTests);
+    return atf_print_results();
+}
+```
 
-Aardvark Test Framework
diff --git a/atf.h b/atf.h
index a486e792e0bed0ca0c1e3e98dd2cdec10d7f9365..f24e9957e0042207a2bac381df134ae31838d757 100755 (executable)
--- a/atf.h
+++ b/atf.h
@@ -52,9 +52,6 @@ int atf_print_results(void);
 
 #define RUN_EXTERN_TEST_SUITE(name) \
     do { extern TEST_SUITE(name); RUN_TEST_SUITE(name); } while(0)
-
-#define PRINT_TEST_RESULTS \
-    atf_print_results
     
 #define EXPECT_EXIT \
     if ((ExitExpected = true, 0 == setjmp(ExitPad)))