Removed double NAME entry.
[AROS.git] / test / exec / rawdofmt.c
blob1942b7d2ca68aeece94c6e466ee1659ee108a0d6
1 #include <exec/rawfmt.h>
2 #include <proto/exec.h>
4 #include <stdio.h>
5 #include <string.h>
7 int __nocommandline = 1;
9 #define TEST(x) \
10 if (x) \
11 printf("Passed\n"); \
12 else \
13 { \
14 printf("Failed\n"); \
15 result |= 1; \
18 int main(void)
20 int result = 0;
21 char buf[256];
22 ULONG count = 0;
23 IPTR args[] =
25 (IPTR)"one",
26 (IPTR)"two",
34 * NewRawDoFmt() should not need 'l' modifier for ULONGs.
35 * This is verified under MorphOS.
37 printf("Checking NewRawDoFmt...\n");
38 NewRawDoFmt("%s plus %s will be %u, next are %u, %u, %u", (APTR)RAWFMTFUNC_COUNT, &count, "one", "two", 3, 4, 5, 6);
39 printf("Count is %u\n", (unsigned)count);
40 TEST(count == 41)
41 NewRawDoFmt("%s plus %s will be %u, next are %u, %u, %u", (APTR)RAWFMTFUNC_STRING, buf, "one", "two", 3, 4, 5, 6);
42 printf("Formatted string is: %s\n", buf);
43 TEST(!strcmp(buf, "one plus two will be 3, next are 4, 5, 6"))
44 NewRawDoFmt("%s plus %s will be %u, next are %u, %u, %u\n", (APTR)RAWFMTFUNC_SERIAL, NULL, "one", "two", 3, 4, 5, 6);
45 printf("Serial output done\n");
47 count = 0;
50 * RawDoFmt() historically assumes UWORD argument
51 * without 'l' modifier. In AROS 'l' here stands for IPTR,
52 * not ULONG, for 64 bit compatibility.
54 printf("Checking RawDoFmt...\n");
55 RawDoFmt("%s plus %s will be %lu, next are %lu, %lu, %lu", args, (APTR)RAWFMTFUNC_COUNT, &count);
56 printf("Count is %u\n", (unsigned)count);
57 TEST(count == 41)
58 RawDoFmt("%s plus %s will be %lu, next are %lu, %lu, %lu", args, (APTR)RAWFMTFUNC_STRING, buf);
59 printf("Formatted string is: %s\n", buf);
60 TEST(!strcmp(buf, "one plus two will be 3, next are 4, 5, 6"))
61 RawDoFmt("%s plus %s will be %lu, next are %lu, %lu, %lu\n", args, (APTR)RAWFMTFUNC_SERIAL, NULL);
62 printf("Serial output done\n");
64 /* Now check correct sign interpretation. Specifier is intentionally %d, not %u! */
65 NewRawDoFmt("This should be positive: %d", (APTR)RAWFMTFUNC_STRING, buf, 40960);
66 printf("NewRawDoFmt sign test: %s\n", buf);
67 TEST(!strcmp(buf, "This should be positive: 40960"))
69 /* Don't depend on endianess, sign-extend on 64 bits */
70 args[0] = (SIPTR)0xA0A0A0A0;
72 /* Intentionally %d with no 'l'! UWORD argument! */
73 RawDoFmt("This should be negative: %d", args, (APTR)RAWFMTFUNC_STRING, buf);
74 printf("RawDoFmt sign test: %s\n", buf);
75 TEST(!strncmp(buf, "This should be negative: -", 26))
77 /* This is actually implemented by locale.library's patch */
78 NewRawDoFmt("%s %llx %llx", (APTR)RAWFMTFUNC_STRING, buf, "Hello", 0x1122334455667788ULL, 0xAABBCCDDEEFF9988ULL);
79 printf("String and two QUADs: %s\n", buf);
80 TEST(!strcmp(buf, "Hello 1122334455667788 AABBCCDDEEFF9988"))
82 return result;