tests: move UTEST_ASSERT() in utest_assert.h

This commit is contained in:
Hugues Delorme 2015-09-14 10:36:39 +02:00
parent 2346927bbc
commit 6e87e42dfe
2 changed files with 25 additions and 8 deletions

23
tests/utest_assert.h Normal file
View File

@ -0,0 +1,23 @@
/* Adapted from minunit
* See : http://www.jera.com/techinfo/jtns/jtn002.html
* http://c.learncodethehardway.org/book/ex30.html
*/
#ifndef UTEST_ASSERT_H
#define UTEST_ASSERT_H
#include <stdio.h>
#define UTEST_ASSERT(test) \
if (!(test)) {\
printf(" ERROR : %s (line = %i, file = %s)", #test, __LINE__, __FILE__);\
return #test;\
}
#define UTEST_ASSERT_MSG(test, message) \
if (!(test)) {\
printf(message);\
return message;\
}
#endif /* UTEST_ASSERT_H */

View File

@ -6,17 +6,11 @@
#ifndef UTEST_LIB_H
#define UTEST_LIB_H
#include <stdio.h>
#include "utest_assert.h"
#include <stdlib.h>
#define UTEST_SUITE_START() const char* message = NULL
#define UTEST_ASSERT(test) if (!(test))\
{ printf(" ERROR : %s (line = %i, file = %s)", #test, __LINE__, __FILE__);\
return #test; }
#define UTEST_ASSERT_MSG(test, message) if (!(test))\
{ printf(message); return message; }
#define UTEST_RUN(test) printf("\n-----%s", " " #test); \
message = test();\