aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: 407c234707f5386344e1cab832ef433dbe328956 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
simple-test
==============

simple unit testing for C implemented as a single header file

brief summary
-------------
Your tests should be written as a single .c file separate from
the body of text containing your functionality to be tested.
Write the tests, include simple-test.h, point your compiler at
the necessary files, and you're done! see this
[documentation (pdf)](https://github.com/shmibs/simple-test/blob/master/README.pdf?raw=true)
for more details (because github markdown is annoying and doesn't
let me colour things).

defined macros
--------------
NAME|DESCRIPTION
---:|:----------
**BEGIN_TEST**|must appear before all tests and after all global variable declarations      
**END_TEST**|must appear at the end of your test program                               
**CLEANUP(statements)**|this defines a list of statements to run when the test exits, either successfully or on a failure. it isn't necessary for a test to run, but, if it does appear, it must be after the declaration of all variables to which it makes reference.
**RETURN()**|place at the end of a test which uses CLEANUP to ensure it is called before the test exits. i couldn't find any way around this without using more than just one header file, so i hope it isn't too annoying.
**STATE(description)**|show a prettily-formatted description of the program's state during a test. takes printf-style arguments.
**EXPECT_ZERO(summary, arg)**|fail if `arg` does not resolve to 0 
**EXPECT_ONE(summary, arg)**|fail if `arg` does not resolve to 1 
**EXPECT_GREATER_THAN_ZERO(summary, arg)**|fail if `arg` does not resolve to a value greater than 0. this will be replaced with more generic integer comparisons soon.  
**EXPECT_INT(summary, arg1, arg2)**|fail if `arg2` does not match the expected integer value `arg1` 
**EXPECT_EQUAL_INT(summary, arg1, arg2)**|fail if `arg1` and `arg2` are not equal 
**EXPECT_UNEQUAL_INT(summary, arg1, arg2)**|fail if `arg1` and `arg2` are equal 
**EXPECT_STR(summary, arg1, arg2)**|fail if string `arg2` does not match the expected string value `arg1` 
**EXPECT_EQUAL_STR(summary, arg1, arg2)**|fail if `arg1` and `arg2` are not equivalent strings 
**EXPECT_UNEQUAL_STR(summary, arg1, arg2)**|fail if `arg1` and `arg2` are equivalent strings 



**WARNING: this will work fine in gcc, but it uses the non-standard
macro \__COUNTER__ and nested functions.**