2 * Copyright (C) 2011-2014, The AROS Development Team. All rights reserved.
3 * Author: Jason S. McMullan <jason.mcmullan@gmail.com>
5 * Licensed under the AROS PUBLIC LICENSE (APL) Version 1.1
11 #include <proto/alib.h>
12 #include <proto/exec.h>
13 #include <proto/dos.h>
15 #include <dos/stdio.h>
16 #include <exec/lists.h>
19 /* For compatability with AOS, our test reference,
22 static AROS_UFH2(VOID
, _SPutC
,
23 AROS_UFHA(BYTE
, c
, D0
),
24 AROS_UFHA(BYTE
**, ptr
, A3
))
35 VOID
SPrintf( char *target
, const char *format
, ...)
37 RawDoFmt( format
, (APTR
)&(((ULONG
*)&format
)[1]), _SPutC
, &target
);
40 #define SPrintf(target,format,args...) __sprintf(target,format ,##args )
43 #define TESTING_BEGINS() \
45 int tests = 0, tests_failed = 0;
47 #define TESTING_ENDS() \
48 if (tests_failed == 0) Printf("All %ld tests passed\n", (LONG)tests); \
49 else Printf("%ld of %ld tests failed\n", (LONG)tests_failed, (LONG)tests); \
51 return (tests_failed == 0) ? RETURN_OK : RETURN_FAIL; \
55 #define TEST_START(name) do { \
56 CONST_STRPTR test_name = #name ; \
57 struct List expr_list; \
63 #define _STRINGED(x) #x
64 #define STRINGED(x) _STRINGED(x)
66 #define VERIFY_EQ(retval, expected) \
68 __typeof__(retval) val = retval; \
70 if (val != (expected)) { \
71 static char buff[128]; \
72 static struct Node expr_node; \
73 SPrintf(buff, "%ld.%ld %s (%ld) != %ld", tests, subtest, STRINGED(retval), (LONG)(IPTR)val, (LONG)(IPTR)expected); \
74 expr_node.ln_Name = buff; \
75 AddTail(&expr_list, &expr_node); \
80 #define VERIFY_NEQ(retval, expected) \
82 __typeof__(retval) val = retval; \
84 if (val == (expected)) { \
85 static char buff[128]; \
86 static struct Node expr_node; \
87 SPrintf(buff, "%ld.%ld %s (%ld) == %ld", tests, subtest, STRINGED(retval) , (LONG)(IPTR)val, (LONG)(IPTR)expected); \
88 expr_node.ln_Name = buff; \
89 AddTail(&expr_list, &expr_node); \
94 #define VERIFY_RET(func, ret, reterr) \
97 VERIFY_EQ(func, ret); \
99 VERIFY_EQ(IoErr(), reterr); \
107 Printf("Test %ld: Failed (%s)\n", (LONG)tests, test_name); \
108 ForeachNode(&expr_list, node) { \
109 Printf("\t%s\n", node->ln_Name); \
114 #endif /* TESTFRAME_H */