Corrected handler name (even if this file isn't used on AROS).
[AROS.git] / test / clib / sprintf.c
blob42a0d716db2b7c4aca3040adf75cec0d8be658e9
1 #include "test.h"
2 #include <stdio.h>
3 #include <string.h>
5 #define TESTNUMBER1 11
6 #define TESTNUMBER1STRLEN 2
7 #define TEST1RESULT "11"
8 #define TEST2RESULT "11"
9 #define TEST3RESULT "11"
11 #define BUFSIZE 10
13 static void cleanbuffer(char * buf)
15 memset(buf, 0xff, BUFSIZE);
18 static int stringsame(char * c1, char * c2, int size)
20 int i;
21 for(i = 0; i < size; i++)
22 if (c1[i] != c2[i]) return 0;
23 return 1;
26 int main()
28 char buf[BUFSIZE];
29 int n1 = TESTNUMBER1;
30 long long n2 = TESTNUMBER1;
31 long long n3 = TESTNUMBER1;
34 /* check standard %d conversion */
35 cleanbuffer(buf);
36 TEST((sprintf(buf, "%d", n1) == TESTNUMBER1STRLEN));
37 TEST((stringsame(buf, TEST1RESULT, TESTNUMBER1STRLEN) == 1));
39 /* check standard %qd conversion */
40 cleanbuffer(buf);
41 TEST((sprintf(buf, "%qd", n2) == TESTNUMBER1STRLEN));
42 TEST((stringsame(buf, TEST2RESULT, TESTNUMBER1STRLEN) == 1));
44 /* check standard %lld conversion */
45 cleanbuffer(buf);
46 TEST((sprintf(buf, "%lld", n3) == TESTNUMBER1STRLEN));
47 TEST((stringsame(buf, TEST3RESULT, TESTNUMBER1STRLEN) == 1));
49 return OK;
52 void cleanup()