6 /* basic: reading of three-char string */
7 SCANF_TEST( 1, "foo", "%3c", buffer );
8 TESTCASE( memcmp( buffer, "foo", 3 ) == 0 );
9 #ifndef TEST_CONVERSION_ONLY
11 SCANF_TEST( 1, "%x", "%%%c", buffer );
12 TESTCASE( buffer[0] == 'x' );
13 /* * to skip assignment */
14 SCANF_TEST( 1, "3xfoo", "%*dx%3c", buffer );
15 TESTCASE( memcmp( buffer, "foo", 3 ) == 0 );
17 /* domain testing on 'int' type */
18 SCANF_TEST( 1, "-" INT_MIN_DEZ_STR, "%d", &i );
19 TESTCASE( i == INT_MIN );
20 SCANF_TEST( 1, INT_MAX_DEZ_STR, "%d", &i );
21 TESTCASE( i == INT_MAX );
22 SCANF_TEST( 1, "-1", "%d", &i );
24 SCANF_TEST( 1, "0", "%d", &i );
26 SCANF_TEST( 1, "1", "%d", &i );
28 SCANF_TEST( 1, "-" INT_MIN_DEZ_STR, "%i", &i );
29 TESTCASE( i == INT_MIN );
30 SCANF_TEST( 1, INT_MAX_DEZ_STR, "%i", &i );
31 TESTCASE( i == INT_MAX );
32 SCANF_TEST( 1, "-1", "%i", &i );
34 SCANF_TEST( 1, "0", "%i", &i );
36 SCANF_TEST( 1, "1", "%i", &i );
38 SCANF_TEST( 1, "0x7" INT_HEXDIG, "%i", &i );
39 TESTCASE( i == INT_MAX );
40 SCANF_TEST( 1, "0x0", "%i", &i );
42 #ifndef TEST_CONVERSION_ONLY
43 SCANF_TEST( 1, "00", "%i%n", &i, &u );
47 /* domain testing on 'unsigned int' type */
48 SCANF_TEST( 1, UINT_MAX_DEZ_STR, "%u", &u );
49 TESTCASE( u == UINT_MAX );
50 SCANF_TEST( 1, "0", "%u", &u );
52 SCANF_TEST( 1, "f" INT_HEXDIG, "%x", &u );
53 TESTCASE( u == UINT_MAX );
54 SCANF_TEST( 1, "7" INT_HEXDIG, "%x", &u );
55 TESTCASE( u == INT_MAX );
56 SCANF_TEST( 1, "0", "%o", &u );
58 SCANF_TEST( 1, INT_OCTDIG, "%o", &u );
59 TESTCASE( u == UINT_MAX );
61 memset( buffer, '\0', 100 );
62 SCANF_TEST( 1, "x", "%c", buffer );
63 TESTCASE( memcmp( buffer, "x\0", 2 ) == 0 );
65 memset( buffer, '\0', 100 );
66 SCANF_TEST( 1, "foo bar", "%s", buffer );
67 TESTCASE( memcmp( buffer, "foo\0", 4 ) == 0 );
68 #ifndef TEST_CONVERSION_ONLY
69 SCANF_TEST( 2, "foo bar baz", "%s %s %n", buffer, buffer + 4, &u );
71 TESTCASE( memcmp( buffer, "foo\0bar\0", 8 ) == 0 );
74 SCANF_TEST( 1, "abcdefg", "%[cba]", buffer );
75 TESTCASE( memcmp( buffer, "abc\0", 4 ) == 0 );
78 sprintf( buffer, "%p", p );
80 SCANF_TEST( 1, buffer, "%p", &p );
81 TESTCASE( p == NULL );
83 sprintf( buffer, "%p", p );
85 SCANF_TEST( 1, buffer, "%p", &p );