77872c0e4ce86b8862b46a63929d095bffc5dc21
[pkgdev.git] / R / CunitTestsMacros.R
1 # Functions to assert that a condition is true or false in C tests
2
3 # Macros to pass file name and line number (in user files [TOFIX])
4 #define ASSERT_TRUE(x,y) assertTrue(__FILE__,__LINE__,x,y)
5 #define ASSERT_FALSE(x,y) assertFalse(__FILE__,__LINE__,x,y)
6
7 CunitTestsMacros = '
8 #include <stdlib.h>
9 #include <stdio.h>
10
11 // Functions to assert that a condition is true or false [to be extended]
12 void assertTrue(char* fileName, int lineNumber, int condition, char* message) {
13 if (!condition) {
14 printf(">>> Failure in file %s at line %i: %s\\n", fileName, lineNumber, message);
15 }
16 }
17
18 void assertFalse(char* fileName, int lineNumber, int condition, char* message) {
19 assertTrue(fileName, lineNumber, !condition, message);
20 }
21 '