tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / test / clib / sscanf.c
blob2ab819d5eb26c77920f823bb7824a61b037781fd
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <stdio.h>
7 #include <string.h>
9 #include "test.h"
11 int main(void)
13 char s[10];
14 static char text1[] = "1.3 1 string";
15 static char text2[] = "NO_NUMBERS_TEXT";
16 static char text3[] = "FSOMETHING";
17 static char text4[] = "0xAF"; /* Hex integer */
18 static char text5[] = "xAF"; /* "Hex integer" without 0 */
19 static char text6[] = "AF"; /* "Hex integer" without 0x */
20 int i, cnt;
21 float f;
23 cnt = sscanf(text1, "%f %d %s", &f, &i, s);
24 TEST(cnt == 3);
25 TEST(f == 1.3f);
26 TEST(i == 1);
27 TEST(strcmp(s, "string") == 0);
29 i = 123456;
30 cnt = sscanf(text2, "%i", &i);
31 TEST(cnt == 0);
32 TEST(i == 123456);
34 i = 123456;
35 cnt = sscanf(text3, "%i", &i);
36 TEST(cnt == 0);
37 TEST(i == 123456);
39 i = 123456;
40 cnt = sscanf(text4, "%i", &i);
41 TEST(cnt == 1);
42 TEST(i == 0xAF);
44 i = 123456;
45 cnt = sscanf(text5, "%i", &i);
46 TEST(cnt == 0);
47 TEST(i == 123456);
49 i = 123456;
50 cnt = sscanf(text6, "%i", &i);
51 TEST(cnt == 0);
52 TEST(i == 123456);
54 cnt = sscanf("0.1", "%f", &f);
55 TEST(cnt == 1);
57 cnt = sscanf(".1", "%f", &f);
58 TEST(cnt == 1);
60 cnt = sscanf("1", "%f", &f);
61 TEST(cnt == 1);
63 cnt = sscanf("-.1", "%f", &f);
64 TEST(cnt == 1);
66 cnt = sscanf("x", "%f", &f);
67 TEST(cnt == 0);
69 return 0;
72 void cleanup(void) {}