diff options
| author | katherine <shmibs@shmibbles.me> | 2018-03-21 00:59:40 -0700 | 
|---|---|---|
| committer | katherine <shmibs@shmibbles.me> | 2018-03-21 00:59:40 -0700 | 
| commit | 8561b9541e1d9d6361e66c9d9bb205b21f065bea (patch) | |
| tree | 9345777617cf68cc15bcb77d15dc20f4ca67205f /doc/a_simple_example.c | |
| parent | f9c70252b3a44dca6bc7313319e501cac28df6c2 (diff) | |
| download | simple-test-8561b9541e1d9d6361e66c9d9bb205b21f065bea.tar.gz | |
update documentation for new version
Diffstat (limited to 'doc/a_simple_example.c')
| -rw-r--r-- | doc/a_simple_example.c | 68 | 
1 files changed, 0 insertions, 68 deletions
| diff --git a/doc/a_simple_example.c b/doc/a_simple_example.c deleted file mode 100644 index 6784713..0000000 --- a/doc/a_simple_example.c +++ /dev/null @@ -1,68 +0,0 @@ -/* keep this include at the very top of the file */ -#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") -{ -	/* 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.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") -{ -	int i; -	char array1[][10] = { -		"str1", -		"str2", -		"str3", -	}; -	char array2[][10] = { -		"str1", -		"str2", -		/* matching will fail here */ -		"different", -	}; - -	for(i = 0; i < sizeof(array1) / sizeof(char[10]); i++) { -		/* ECHO can be used to print (with pretty -		 * formatting) the current state within the -		 * test */ -		ECHO("checking strs at i == %i", i); - -		ASSERT_STR_EQ(array1[i], array2[i]); -	} -} - -/* must come after all TESTs */ -END_TEST | 
