diff options
author | shmibs <shmibs@gmail.com> | 2015-12-22 14:31:25 -0700 |
---|---|---|
committer | shmibs <shmibs@gmail.com> | 2015-12-22 14:31:25 -0700 |
commit | 801460e0e42ddf53788397b31fb8291b4f4ff463 (patch) | |
tree | f43b1ad9eb4cc0e9d3ca1a19d710fbfcd0e3a2ed /doc | |
parent | 161c3f0d10e4b93697267ed04b28e7285611a7eb (diff) | |
download | simple-test-801460e0e42ddf53788397b31fb8291b4f4ff463.tar.gz |
reference files for README.md
Diffstat (limited to 'doc')
-rw-r--r-- | doc/a_simple_example.c | 35 | ||||
-rw-r--r-- | doc/run-01.png | bin | 0 -> 2766 bytes | |||
-rw-r--r-- | doc/run-02.png | bin | 0 -> 1065 bytes | |||
-rw-r--r-- | doc/run-03.png | bin | 0 -> 1273 bytes |
4 files changed, 29 insertions, 6 deletions
diff --git a/doc/a_simple_example.c b/doc/a_simple_example.c index 2153a70..6784713 100644 --- a/doc/a_simple_example.c +++ b/doc/a_simple_example.c @@ -1,21 +1,42 @@ /* keep this include at the very top of the file */ -#include "simple-test.h" +#include "../src/simple-test.h" /* any global variables, functions, other inclusions, etc. * should be declared here */ #include "header_with_stuff_to_be_tested.h" +int add_here(int a, int b) +{ + /* ASSERT / ECHO statements within functions + * like this are perfectly valid. this is + * useful for writing initialisation functions + * called at the beginning of multiple TESTs */ + ECHO("this is the local add"); + + /* ensure a and b are non-0 using generic ASSERT */ + ASSERT(a); + ASSERT(b); + + return a + b; +} + +/* must come before all TESTs */ BEGIN_TEST /* the string is a description of the test being run */ TEST("check add()'s return value") { - int var1=2; - int var2=4; + /* mixing different precisions is allowed */ + long var1 = 2; + int8_t var2 = 2; /* add is a function included from our hypothetical - * header_with_stuff_to_be_tested */ - EXPECT_INT(var1+var2, add(var1, var2)); + * header_with_stuff_to_be_tested.h */ + ASSERT_INT_EQ(var1+var2, add(var1, var2)); + + /* generic versions of ASSERTions are also valid, + * but only for number types (int / uint / float ) */ + ASSERT_EQ(var1+var2, add_here(var1, var2)); } TEST("compare two arrays of strings") @@ -38,8 +59,10 @@ TEST("compare two arrays of strings") * formatting) the current state within the * test */ ECHO("checking strs at i == %i", i); - EXPECT_STR_EQ(array1[i], array2[i]); + + ASSERT_STR_EQ(array1[i], array2[i]); } } +/* must come after all TESTs */ END_TEST diff --git a/doc/run-01.png b/doc/run-01.png Binary files differnew file mode 100644 index 0000000..b7c6838 --- /dev/null +++ b/doc/run-01.png diff --git a/doc/run-02.png b/doc/run-02.png Binary files differnew file mode 100644 index 0000000..aedd395 --- /dev/null +++ b/doc/run-02.png diff --git a/doc/run-03.png b/doc/run-03.png Binary files differnew file mode 100644 index 0000000..f6843dc --- /dev/null +++ b/doc/run-03.png |