Corrected handler name (even if this file isn't used on AROS).
[AROS.git] / test / clib / sscanf.c
blobce95fd7e70effc82816818fc5853e787501d06dc
1 #include <stdio.h>
2 #include <string.h>
4 #include "test.h"
6 int main(void)
8 char s[10];
9 static char text1[] = "1.3 1 string";
10 static char text2[] = "NO_NUMBERS_TEXT";
11 static char text3[] = "FSOMETHING";
12 static char text4[] = "0xAF"; /* Hex integer */
13 static char text5[] = "xAF"; /* "Hex integer" without 0 */
14 static char text6[] = "AF"; /* "Hex integer" without 0x */
15 int i, cnt;
16 float f;
18 cnt = sscanf(text1, "%f %d %s", &f, &i, s);
19 TEST(cnt == 3);
20 TEST(f == 1.3f);
21 TEST(i == 1);
22 TEST(strcmp(s, "string") == 0);
24 i = 123456;
25 cnt = sscanf(text2, "%i", &i);
26 TEST(cnt == 0);
27 TEST(i == 123456);
29 i = 123456;
30 cnt = sscanf(text3, "%i", &i);
31 TEST(cnt == 0);
32 TEST(i == 123456);
34 i = 123456;
35 cnt = sscanf(text4, "%i", &i);
36 TEST(cnt == 1);
37 TEST(i == 0xAF);
39 i = 123456;
40 cnt = sscanf(text5, "%i", &i);
41 TEST(cnt == 0);
42 TEST(i == 123456);
44 i = 123456;
45 cnt = sscanf(text6, "%i", &i);
46 TEST(cnt == 0);
47 TEST(i == 123456);
49 cnt = sscanf("0.1", "%f", &f);
50 TEST(cnt == 1);
52 cnt = sscanf(".1", "%f", &f);
53 TEST(cnt == 1);
55 cnt = sscanf("1", "%f", &f);
56 TEST(cnt == 1);
58 cnt = sscanf("-.1", "%f", &f);
59 TEST(cnt == 1);
61 cnt = sscanf("x", "%f", &f);
62 TEST(cnt == 0);
64 return 0;
67 void cleanup(void) {}