Split off testing API into header, separate from source
This is so I could generate new test units using the same API.
This commit is contained in:
47
test/test.h
Normal file
47
test/test.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* test.h: Unit test API
|
||||
* Created: 2026-02-04
|
||||
* Author: Aryadev Chavali
|
||||
* License: See end of file
|
||||
* Commentary:
|
||||
*/
|
||||
|
||||
#ifndef TEST_H
|
||||
#define TEST_H
|
||||
|
||||
#include <alisp/alisp.h>
|
||||
|
||||
#define TEST_PASSED() printf("[%s]: Passed\n", __func__)
|
||||
#define TEST(COND, ...) \
|
||||
do \
|
||||
{ \
|
||||
bool cond = (COND); \
|
||||
if (!cond) \
|
||||
{ \
|
||||
printf("\tFAIL: "); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
printf("\tPASS: "); \
|
||||
} \
|
||||
printf("%s => ", #COND); \
|
||||
printf(__VA_ARGS__); \
|
||||
printf("\n"); \
|
||||
if (!cond) \
|
||||
{ \
|
||||
assert(0); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
/* Copyright (C) 2026 Aryadev Chavali
|
||||
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the Unlicense for details.
|
||||
|
||||
* You may distribute and modify this code under the terms of the Unlicense,
|
||||
* which you should have received a copy of along with this program. If not,
|
||||
* please go to <https://unlicense.org/>.
|
||||
|
||||
*/
|
||||
Reference in New Issue
Block a user