Check for SYS/GL during library init. Reason is that
[AROS.git] / test / exec / rawdofmt.c
blob750daf11e8a6b0c31c3833d30103daca4b1b8450
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <exec/rawfmt.h>
7 #include <proto/exec.h>
9 #include <stdio.h>
10 #include <string.h>
12 int __nocommandline = 1;
14 #define TEST(x) \
15 if (x) \
16 printf("Passed\n"); \
17 else \
18 { \
19 printf("Failed\n"); \
20 result |= 1; \
23 int main(void)
25 int result = 0;
26 char buf[256];
27 ULONG count = 0;
28 struct {
29 CONST_STRPTR one;
30 CONST_STRPTR two;
31 ULONG three,four,five,size;
32 } __packed args = {
33 "one",
34 "two",
42 * NewRawDoFmt() should not need 'l' modifier for ULONGs.
43 * This is verified under MorphOS.
45 printf("Checking NewRawDoFmt...\n");
46 NewRawDoFmt("%s plus %s will be %u, next are %u, %u, %u", (APTR)RAWFMTFUNC_COUNT, &count, "one", "two", 3, 4, 5, 6);
47 printf("Count is %u\n", (unsigned)count);
48 TEST(count == 41)
49 NewRawDoFmt("%s plus %s will be %u, next are %u, %u, %u", (APTR)RAWFMTFUNC_STRING, buf, "one", "two", 3, 4, 5, 6);
50 printf("Formatted string is: %s\n", buf);
51 TEST(!strcmp(buf, "one plus two will be 3, next are 4, 5, 6"))
52 NewRawDoFmt("%s plus %s will be %u, next are %u, %u, %u\n", (APTR)RAWFMTFUNC_SERIAL, NULL, "one", "two", 3, 4, 5, 6);
53 printf("Serial output done\n");
55 count = 0;
58 * RawDoFmt() historically assumes UWORD argument
59 * without 'l' modifier. In AROS 'l' here stands for IPTR,
60 * not ULONG, for 64 bit compatibility.
62 printf("Checking RawDoFmt...\n");
63 RawDoFmt("%s plus %s will be %lu, next are %lu, %lu, %lu", (RAWARG)&args, (APTR)RAWFMTFUNC_COUNT, &count);
64 printf("Count is %u\n", (unsigned)count);
65 TEST(count == 41)
66 RawDoFmt("%s plus %s will be %lu, next are %lu, %lu, %lu", (RAWARG)&args, (APTR)RAWFMTFUNC_STRING, buf);
67 printf("Formatted string is: %s\n", buf);
68 TEST(!strcmp(buf, "one plus two will be 3, next are 4, 5, 6"))
69 RawDoFmt("%s plus %s will be %lu, next are %lu, %lu, %lu\n", (RAWARG)&args, (APTR)RAWFMTFUNC_SERIAL, NULL);
70 printf("Serial output done\n");
72 /* Now check correct sign interpretation. Specifier is intentionally %d, not %u! */
73 NewRawDoFmt("This should be positive: %d", (APTR)RAWFMTFUNC_STRING, buf, 40960);
74 printf("NewRawDoFmt sign test: %s\n", buf);
75 TEST(!strcmp(buf, "This should be positive: 40960"))
77 /* Don't depend on endianess, sign-extend on 64 bits */
78 args.three = 0xA0A0A0A0;
80 /* Intentionally %d with no 'l'! UWORD argument! */
81 RawDoFmt("This should be negative: %d", (RAWARG)&args.three, (APTR)RAWFMTFUNC_STRING, buf);
82 printf("RawDoFmt sign test: %s\n", buf);
83 TEST(!strncmp(buf, "This should be negative: -", 26))
85 /* This is actually implemented by locale.library's patch */
86 NewRawDoFmt("%s %llx %llx", (APTR)RAWFMTFUNC_STRING, buf, "Hello", 0x1122334455667788ULL, 0xAABBCCDDEEFF9988ULL);
87 printf("String and two QUADs: %s\n", buf);
88 TEST(!strcmp(buf, "Hello 1122334455667788 AABBCCDDEEFF9988"))
90 return result;