xaizek / stic (License: MIT) (since 2018-12-07)
Simple Tests In C with optional automatic test registration in C.
Commit 3cf7c126d23902a08359398fd1836299d69bf9c3

Print test name, not functions with assert in stic
One can deduce function name from line anyway, but if several tests
call same auxiliary function report becomes ambiguous rather than
helpful.
Author: xaizek
Author date (UTC): 2015-04-26 20:16
Committer name: xaizek
Committer date (UTC): 2015-04-29 17:44
Parent(s): f26df5cc4401e429b0e57b58ce629d9bde190a8a
Signing key:
Tree: 8452d371a18122d98244caf746a82692e6a5b173
File Lines added Lines deleted
src/stic.c 9 4
src/stic.h 3 0
File src/stic.c changed (mode: 100644) (index 2fa70a1..1940128)
... ... static stic_void_void stic_suite_teardown_func = 0;
83 83 static stic_void_void stic_fixture_setup = 0; static stic_void_void stic_fixture_setup = 0;
84 84 static stic_void_void stic_fixture_teardown = 0; static stic_void_void stic_fixture_teardown = 0;
85 85
86 const char *stic_current_test;
87
86 88 void (*stic_simple_test_result)(int passed, char* reason, const char* function, unsigned int line) = stic_simple_test_result_log; void (*stic_simple_test_result)(int passed, char* reason, const char* function, unsigned int line) = stic_simple_test_result_log;
87 89
88 90 void suite_setup(stic_void_void setup) void suite_setup(stic_void_void setup)
 
... ... static int stic_fixture_tests_failed;
154 156
155 157 void stic_simple_test_result_log(int passed, char* reason, const char* function, unsigned int line) void stic_simple_test_result_log(int passed, char* reason, const char* function, unsigned int line)
156 158 { {
159 /* TODO: do use function if it differs from test. */
160 (void)function;
161
157 162 if (!passed) if (!passed)
158 163 { {
159 164 if(stic_machine_readable) if(stic_machine_readable)
160 165 { {
161 printf("%s%s,%s,%u,%s\n", stic_magic_marker, stic_current_fixture_path, function, line, reason );
166 printf("%s%s,%s,%u,%s\n", stic_magic_marker, stic_current_fixture_path, stic_current_test, line, reason );
162 167 } }
163 168 else else
164 169 { {
165 printf("%-30s Line %-5d %s\n", function, line, reason );
170 printf("%-30s Line %-5d %s\n", stic_current_test, line, reason );
166 171 } }
167 172 sea_tests_failed++; sea_tests_failed++;
168 173 } }
 
... ... void stic_simple_test_result_log(int passed, char* reason, const char* function,
172 177 { {
173 178 if(stic_machine_readable) if(stic_machine_readable)
174 179 { {
175 printf("%s%s,%s,%u,Passed\n", stic_magic_marker, stic_current_fixture_path, function, line );
180 printf("%s%s,%s,%u,Passed\n", stic_magic_marker, stic_current_fixture_path, stic_current_test, line );
176 181 } }
177 182 else else
178 183 { {
179 printf("%-30s Line %-5d Passed\n", function, line);
184 printf("%-30s Line %-5d Passed\n", stic_current_test, line);
180 185 } }
181 186 } }
182 187 sea_tests_passed++; sea_tests_passed++;
File src/stic.h changed (mode: 100644) (index 6ee327d..2a1b2b8)
... ... static void stic_fixture(void)
305 305
306 306 for(i = 0; i < STIC_ARRAY_LEN(test_data); ++i) for(i = 0; i < STIC_ARRAY_LEN(test_data); ++i)
307 307 { {
308 extern const char *stic_current_test;
309
308 310 struct stic_test_data *td = *test_data[i]; struct stic_test_data *td = *test_data[i];
309 311 if(td == NULL) continue; if(td == NULL) continue;
310 312 if(td->p != NULL && !td->p()) continue; if(td->p != NULL && !td->p()) continue;
311 313 if(!stic_should_run(fixture_name, td->n)) continue; if(!stic_should_run(fixture_name, td->n)) continue;
312 314
315 stic_current_test = td->n;
313 316 stic_suite_setup(); stic_suite_setup();
314 317 stic_setup(); stic_setup();
315 318 td->t(); td->t();
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/stic

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/stic

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master