Copyright clean-up (part 1):
[AROS.git] / test / exec / rawdofmt.c
blob4be4b33a8ee35db2bc803f458db834450dce5ac3
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 IPTR args[] =
30 (IPTR)"one",
31 (IPTR)"two",
39 * NewRawDoFmt() should not need 'l' modifier for ULONGs.
40 * This is verified under MorphOS.
42 printf("Checking NewRawDoFmt...\n");
43 NewRawDoFmt("%s plus %s will be %u, next are %u, %u, %u", (APTR)RAWFMTFUNC_COUNT, &count, "one", "two", 3, 4, 5, 6);
44 printf("Count is %u\n", (unsigned)count);
45 TEST(count == 41)
46 NewRawDoFmt("%s plus %s will be %u, next are %u, %u, %u", (APTR)RAWFMTFUNC_STRING, buf, "one", "two", 3, 4, 5, 6);
47 printf("Formatted string is: %s\n", buf);
48 TEST(!strcmp(buf, "one plus two will be 3, next are 4, 5, 6"))
49 NewRawDoFmt("%s plus %s will be %u, next are %u, %u, %u\n", (APTR)RAWFMTFUNC_SERIAL, NULL, "one", "two", 3, 4, 5, 6);
50 printf("Serial output done\n");
52 count = 0;
55 * RawDoFmt() historically assumes UWORD argument
56 * without 'l' modifier. In AROS 'l' here stands for IPTR,
57 * not ULONG, for 64 bit compatibility.
59 printf("Checking RawDoFmt...\n");
60 RawDoFmt("%s plus %s will be %lu, next are %lu, %lu, %lu", args, (APTR)RAWFMTFUNC_COUNT, &count);
61 printf("Count is %u\n", (unsigned)count);
62 TEST(count == 41)
63 RawDoFmt("%s plus %s will be %lu, next are %lu, %lu, %lu", args, (APTR)RAWFMTFUNC_STRING, buf);
64 printf("Formatted string is: %s\n", buf);
65 TEST(!strcmp(buf, "one plus two will be 3, next are 4, 5, 6"))
66 RawDoFmt("%s plus %s will be %lu, next are %lu, %lu, %lu\n", args, (APTR)RAWFMTFUNC_SERIAL, NULL);
67 printf("Serial output done\n");
69 /* Now check correct sign interpretation. Specifier is intentionally %d, not %u! */
70 NewRawDoFmt("This should be positive: %d", (APTR)RAWFMTFUNC_STRING, buf, 40960);
71 printf("NewRawDoFmt sign test: %s\n", buf);
72 TEST(!strcmp(buf, "This should be positive: 40960"))
74 /* Don't depend on endianess, sign-extend on 64 bits */
75 args[0] = (SIPTR)0xA0A0A0A0;
77 /* Intentionally %d with no 'l'! UWORD argument! */
78 RawDoFmt("This should be negative: %d", args, (APTR)RAWFMTFUNC_STRING, buf);
79 printf("RawDoFmt sign test: %s\n", buf);
80 TEST(!strncmp(buf, "This should be negative: -", 26))
82 /* This is actually implemented by locale.library's patch */
83 NewRawDoFmt("%s %llx %llx", (APTR)RAWFMTFUNC_STRING, buf, "Hello", 0x1122334455667788ULL, 0xAABBCCDDEEFF9988ULL);
84 printf("String and two QUADs: %s\n", buf);
85 TEST(!strcmp(buf, "Hello 1122334455667788 AABBCCDDEEFF9988"))
87 return result;