-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.c
89 lines (70 loc) · 2.56 KB
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifdef __SASC
# define CONST_STRPTR const STRPTR
# define CONST const
#endif
#include <clib/debug_protos.h>
static const char KPutStr_str[] = " 1: Testing KPutStr\n";
static const char kputs_str[] = " 2: Testing kputs\n";
static const char KPutS_str[] = " 3: Testing KPutS\n";
static const char KPutChar_str[] = " 4: Testing KPutChar\n";
static const char kputc_str[] = " 5: Testing kputc\n";
static const char kputchar_str[] = " 6: Testing kputchar\n";
static const char kputch_str[] = " 7: Testing kputch\n";
static const char KPutCh_str[] = " 8: Testing KPutCh\n";
static const char KPutFmt_str[] = " 9: Testing KPutFmt: %ld-1 is 0x%lx\n";
static const char KVPrintF_str[] = "10: Testing KVPrintF: %ld-1 is 0x%lx\n";
static const char KPrintF_str[] = "11: Testing KPrintF & KCmpStr: %ld %ld %ld\n";
static const char kprintf_str[] = "12: Testing kprintf & cmpstrexec: %ld %ld %ld\n";
static const char KDoFmt_str[] = "13: Testing KDoFmt+KPutChar: %ld-1 is 0x%lx\n";
static const char KDoFmt2_str[] = "14: Testing KDoFmt+custom: %ld-1 is 0x%lx\n";
static const char KGetChar_str[] = "15: Testing KGetChar: ";
static const char kgetc_str[] = "16: Testing kgetc: ";
static const char kgetchar_str[] = "17: Testing kgetchar: ";
static const char kgetch_str[] = "18: Testing kgetch: ";
static const char KGetCh_str[] = "19: Testing KGetCh: ";
static void puts(const char* str, void (*func)(long c)) {
while (TRUE) {
if (*str == 0) {
break;
}
func(*str++);
}
}
static void putChProc(LONG c, APTR data) {
if (data == (APTR) 0x01234567) {
KPutCh(c);
}
else {
KPutCh('?');
}
}
static void test_getc(CONST_STRPTR str, LONG (*func)(VOID)) {
LONG c;
kputs(str);
c = func();
kprintf("Got char %ld\n", c);
}
int main(void) {
ULONG args[] = { 262145, 262144 };
KPutStr(KPutStr_str);
kputs(kputs_str);
KPutS(KPutS_str);
puts(KPutChar_str, KPutChar);
puts(kputc_str, kputc);
puts(kputchar_str, kputchar);
puts(kputch_str, kputch);
puts(KPutCh_str, KPutCh);
KPutFmt(KPutFmt_str, args);
KVPrintF(KVPrintF_str, args);
KPrintF(KPrintF_str, KCmpStr("A","B1"), KCmpStr("B1","A"), KCmpStr("A1","A1"));
KPrintF(kprintf_str, cmpstrexec("aaa", "aa"), cmpstrexec("aa", "aaa"), cmpstrexec("aaa", "aaa"));
KDoFmt(KDoFmt_str, args, KPutChar, NULL);
KDoFmt(KDoFmt2_str, args, putChProc, (APTR) 0x01234567);
kputs("\nTesting input\n");
test_getc(KGetChar_str, KGetChar);
test_getc(kgetc_str, kgetc);
test_getc(kgetchar_str, kgetchar);
test_getc(kgetch_str, kgetch);
test_getc(KGetCh_str, KGetCh);
return 0;
}