Add some warnings in README
[pkgdev.git] / R / CunitTestsMacros.R
... / ...
CommitLineData
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
7CunitTestsMacros = '
8#include <stdlib.h>
9#include <stdio.h>
10
11// Functions to assert that a condition is true or false [to be extended]
12void 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
18void assertFalse(char* fileName, int lineNumber, int condition, char* message) {
19 assertTrue(fileName, lineNumber, !condition, message);
20}
21'