2 * Copyright (C) 2011, 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
8 #include <aros/debug.h>
9 #include <proto/alib.h>
10 #include <proto/exec.h>
11 #include <proto/dos.h>
13 #include <dos/stdio.h>
14 #include <exec/lists.h>
17 /* For compatability with AOS, our test reference */
18 static AROS_UFH2(VOID
, _SPutC
,
19 AROS_UFHA(BYTE
, c
, D0
),
20 AROS_UFHA(BYTE
**, ptr
, A3
))
31 VOID
SPrintf( char *target
, const char *format
, ...)
33 RawDoFmt( format
, (APTR
)&(((ULONG
*)&format
)[1]), _SPutC
, &target
);
36 #define SPrintf(buff,format,args...) __sprintf(buff,format ,##args )
39 #define TEST_START(name) do { \
40 CONST_STRPTR test_name = #name ; \
41 struct List expr_list; \
46 #define VERIFY_EQ(retval, expected) \
48 __typeof__(retval) val = retval; \
49 if (val != (expected)) { \
50 static char buff[128]; \
51 static struct Node expr_node; \
52 SPrintf(buff, "%s (%ld) != %ld", #retval , (LONG)val, (LONG)expected); \
53 expr_node.ln_Name = buff; \
54 AddTail(&expr_list, &expr_node); \
59 #define VERIFY_RET(func, ret, reterr) \
62 VERIFY_EQ(func, ret); \
63 VERIFY_EQ(IoErr(), reterr); \
70 Printf("Test %ld: Failed (%s)\n", (LONG)tests, test_name); \
71 ForeachNode(&expr_list, node) { \
72 Printf("\t%s\n", node->ln_Name); \
77 int main(int argc
, char **argv
)
80 int tests
= 0, tests_failed
= 0;
82 TEST_START("fd = BNULL");
84 VERIFY_RET(IsInteractive(fd
), DOSFALSE
, -1);
87 TEST_START("fd = Open(\"NIL:\", MODE_OLDFILE)");
88 fd
= Open("NIL:", MODE_OLDFILE
);
89 VERIFY_RET(IsInteractive(fd
), DOSFALSE
, -1);
93 TEST_START("fd = Open(\"NIL:\", MODE_NEWFILE)");
94 fd
= Open("NIL:", MODE_NEWFILE
);
95 VERIFY_RET(IsInteractive(fd
), DOSFALSE
, -1);
99 TEST_START("fd = Open(\"CON:0/0/100/100/Test/CLOSE/AUTO\", MODE_OLDFILE)");
100 fd
= Open("CON:0/0/100/100/Test/CLOSE/AUTO", MODE_OLDFILE
);
101 VERIFY_RET(IsInteractive(fd
), DOSTRUE
, -1);