tests: move UTEST_ASSERT() in utest_assert.h
This commit is contained in:
parent
2346927bbc
commit
6e87e42dfe
23
tests/utest_assert.h
Normal file
23
tests/utest_assert.h
Normal 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 */
|
@ -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();\
|
||||
|
Loading…
Reference in New Issue
Block a user