-// decimal integer matches
-void suite_two()
-{
- char const * string = "-0 +0 -128 +127 +255 -32768 +32767 +65535\n"
- "-2147483648 +2147483647 +4294967295\n"
- "-9223372036854775808 +9223372036854775807\n"
- "+18446744073709551615\n";
- CHECK_EQUAL( string[141], '\n' );
- {
- // reading 0, d
- signed char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 1, "%hhd%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 1 );
- }
- {
- // reading -0, d
- signed char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 0, "%hhd%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading +0, d
- signed char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 3, "%hhd%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading -128, d
- signed char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 6, "%hhd%n", &i, &n ), 1 );
- CHECK_EQUAL( i, -128 );
- CHECK_EQUAL( n, 4 );
- }
- {
- // reading 127, d
- signed char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 12, "%hhd%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 127 );
- CHECK_EQUAL( n, 3 );
- }
- {
- // reading +127, d
- signed char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 11, "%hhd%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 127 );
- CHECK_EQUAL( n, 4 );
- }
- {
- // reading 0, u
- unsigned char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 1, "%hhu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 1 );
- }
- {
- // reading -0, u
- unsigned char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 0, "%hhu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading +0, u
- unsigned char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 3, "%hhu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading 127, u
- unsigned char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 12, "%hhu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 127 );
- CHECK_EQUAL( n, 3 );
- }
- {
- // reading +127, u
- unsigned char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 11, "%hhu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 127 );
- CHECK_EQUAL( n, 4 );
- }
- {
- // reading 255, u
- unsigned char i = 0;
- int n;
- CHECK_EQUAL( sscanf( string + 17, "%hhu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 255 );
- CHECK_EQUAL( n, 3 );
- }
- {
- // reading +255, u
- unsigned char i = 0;
- int n;
- CHECK_EQUAL( sscanf( string + 16, "%hhu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 255 );
- CHECK_EQUAL( n, 4 );
- }
- {
- // reading 0, i
- signed char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 1, "%hhi%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 1 );
- }
- {
- // reading -0, i
- signed char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 0, "%hhi%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading +0, i
- signed char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 3, "%hhi%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading -128, i
- signed char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 6, "%hhi%n", &i, &n ), 1 );
- CHECK_EQUAL( i, -128 );
- CHECK_EQUAL( n, 4 );
- }
- {
- // reading 127, i
- signed char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 12, "%hhi%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 127 );
- CHECK_EQUAL( n, 3 );
- }
- {
- // reading +127, i
- signed char i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 11, "%hhi%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 127 );
- CHECK_EQUAL( n, 4 );
- }
- {
- // reading 0, d
- signed short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 1, "%hd%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 1 );
- }
- {
- // reading -0, d
- signed short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 0, "%hd%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading +0, d
- signed short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 3, "%hd%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading -32768, d
- signed short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 21, "%hd%n", &i, &n ), 1 );
- CHECK_EQUAL( i, -32768 );
- CHECK_EQUAL( n, 6 );
- }
- {
- // reading 32767, d
- signed short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 29, "%hd%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 32767 );
- CHECK_EQUAL( n, 5 );
- }
- {
- // reading +32767, d
- signed short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 28, "%hd%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 32767 );
- CHECK_EQUAL( n, 6 );
- }
- {
- // reading 0, u
- unsigned short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 1, "%hu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 1 );
- }
- {
- // reading -0, u
- unsigned short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 0, "%hu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading +0, u
- unsigned short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 3, "%hu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading 32767, u
- unsigned short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 29, "%hu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 32767 );
- CHECK_EQUAL( n, 5 );
- }
- {
- // reading +32767, u
- unsigned short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 28, "%hu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 32767 );
- CHECK_EQUAL( n, 6 );
- }
- {
- // reading 65535, u
- unsigned short i = 0;
- int n;
- CHECK_EQUAL( sscanf( string + 36, "%hu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 65535 );
- CHECK_EQUAL( n, 5 );
- }
- {
- // reading +65535, u
- unsigned short i = 0;
- int n;
- CHECK_EQUAL( sscanf( string + 35, "%hu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 65535 );
- CHECK_EQUAL( n, 6 );
- }
- {
- // reading 0, i
- signed short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 1, "%hi%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 1 );
- }
- {
- // reading -0, i
- signed short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 0, "%hi%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading +0, i
- signed short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 3, "%hi%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading -32768, i
- signed short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 21, "%hi%n", &i, &n ), 1 );
- CHECK_EQUAL( i, -32768 );
- CHECK_EQUAL( n, 6 );
- }
- {
- // reading 32767, i
- signed short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 29, "%hi%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 32767 );
- CHECK_EQUAL( n, 5 );
- }
- {
- // reading +32767, i
- signed short i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 28, "%hi%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 32767 );
- CHECK_EQUAL( n, 6 );
- }
- {
- // reading 0, d
- signed int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 1, "%d%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 1 );
- }
- {
- // reading -0, d
- signed int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 0, "%d%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading +0, d
- signed int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 3, "%d%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading -2147483648, d
- signed int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 42, "%d%n", &i, &n ), 1 );
- CHECK_EQUAL( i, -2147483648 );
- CHECK_EQUAL( n, 11 );
- }
- {
- // reading 2147483647, d
- signed int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 55, "%d%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 2147483647 );
- CHECK_EQUAL( n, 10 );
- }
- {
- // reading +2147483647, d
- signed int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 54, "%d%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 2147483647 );
- CHECK_EQUAL( n, 11 );
- }
- {
- // reading 0, u
- unsigned int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 1, "%u%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 1 );
- }
- {
- // reading -0, u
- unsigned int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 0, "%u%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading +0, u
- unsigned int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 3, "%u%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading 2147483647, u
- unsigned int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 55, "%u%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 2147483647 );
- CHECK_EQUAL( n, 10 );
- }
- {
- // reading +2147483647, u
- unsigned int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 54, "%u%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 2147483647 );
- CHECK_EQUAL( n, 11 );
- }
- {
- // reading 4294967295, u
- unsigned int i = 0;
- int n;
- CHECK_EQUAL( sscanf( string + 67, "%u%n", &i, &n ), 1 );
- CHECK_FEQUAL( i, 4294967295, unsigned int, "%u" );
- CHECK_EQUAL( n, 10 );
- }
- {
- // reading +4294967295, u
- unsigned int i = 0;
- int n;
- CHECK_EQUAL( sscanf( string + 66, "%u%n", &i, &n ), 1 );
- CHECK_FEQUAL( i, 4294967295, unsigned int, "%u" );
- CHECK_EQUAL( n, 11 );
- }
- {
- // reading 0, i
- signed int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 1, "%i%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 1 );
- }
- {
- // reading -0, i
- signed int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 0, "%i%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading +0, i
- signed int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 3, "%i%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0 );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading -2147483648, i
- signed int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 42, "%i%n", &i, &n ), 1 );
- CHECK_EQUAL( i, -2147483648 );
- CHECK_EQUAL( n, 11 );
- }
- {
- // reading 2147483647, i
- signed int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 55, "%i%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 2147483647 );
- CHECK_EQUAL( n, 10 );
- }
- {
- // reading +2147483647, i
- signed int i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 54, "%i%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 2147483647 );
- CHECK_EQUAL( n, 11 );
- }
- {
- // reading 0, d
- signed long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 1, "%ld%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0l );
- CHECK_EQUAL( n, 1 );
- }
- {
- // reading -0, d
- signed long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 0, "%ld%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0l );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading +0, d
- signed long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 3, "%ld%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0l );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading -2147483648, d
- signed long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 42, "%ld%n", &i, &n ), 1 );
- CHECK_EQUAL( i, -2147483648l );
- CHECK_EQUAL( n, 11 );
- }
- {
- // reading 2147483647, d
- signed long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 55, "%ld%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 2147483647l );
- CHECK_EQUAL( n, 10 );
- }
- {
- // reading +2147483647, d
- signed long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 54, "%ld%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 2147483647l );
- CHECK_EQUAL( n, 11 );
- }
- {
- // reading 0, u
- unsigned long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 1, "%lu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0ul );
- CHECK_EQUAL( n, 1 );
- }
- {
- // reading -0, u
- unsigned long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 0, "%lu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0ul );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading +0, u
- unsigned long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 3, "%lu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0ul );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading 2147483647, u
- unsigned long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 55, "%lu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 2147483647ul );
- CHECK_EQUAL( n, 10 );
- }
- {
- // reading +2147483647, u
- unsigned long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 54, "%lu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 2147483647ul );
- CHECK_EQUAL( n, 11 );
- }
- {
- // reading 4294967295, u
- unsigned long i = 0;
- int n;
- CHECK_EQUAL( sscanf( string + 67, "%lu%n", &i, &n ), 1 );
- CHECK_FEQUAL( i, 4294967295ul, unsigned long, "%lu" );
- CHECK_EQUAL( n, 10 );
- }
- {
- // reading +4294967295, u
- unsigned long i = 0;
- int n;
- CHECK_EQUAL( sscanf( string + 66, "%lu%n", &i, &n ), 1 );
- CHECK_FEQUAL( i, 4294967295ul, unsigned long, "%lu" );
- CHECK_EQUAL( n, 11 );
- }
- {
- // reading 0, i
- signed long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 1, "%li%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0l );
- CHECK_EQUAL( n, 1 );
- }
- {
- // reading -0, i
- signed long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 0, "%li%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0l );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading +0, i
- signed long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 3, "%li%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0l );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading -2147483648, i
- signed long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 42, "%li%n", &i, &n ), 1 );
- CHECK_EQUAL( i, -2147483648l );
- CHECK_EQUAL( n, 11 );
- }
- {
- // reading 2147483647, i
- signed long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 55, "%li%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 2147483647l );
- CHECK_EQUAL( n, 10 );
- }
- {
- // reading +2147483647, i
- signed long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 54, "%li%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 2147483647l );
- CHECK_EQUAL( n, 11 );
- }
- {
- // reading 0, d
- signed long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 1, "%lld%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0ll );
- CHECK_EQUAL( n, 1 );
- }
- {
- // reading -0, d
- signed long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 0, "%lld%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0ll );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading +0, d
- signed long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 3, "%lld%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0ll );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading -9223372036854775808, d
- signed long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 78, "%lld%n", &i, &n ), 1 );
- CHECK_FEQUAL( i, LLONG_MIN, signed long long, "%lld" ); // should be literal -9223372036854775808ll but GCC balks.
- CHECK_EQUAL( i < 0ll, 1 );
- CHECK_EQUAL( n, 20 );
- }
- {
- // reading 9223372036854775807, d
- signed long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 100, "%lld%n", &i, &n ), 1 );
- CHECK_FEQUAL( i, 9223372036854775807ll, signed long long, "%lld" );
- CHECK_EQUAL( n, 19 );
- }
- {
- // reading +9223372036854775807, d
- signed long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 99, "%lld%n", &i, &n ), 1 );
- CHECK_FEQUAL( i, 9223372036854775807ll, signed long long, "%lld" );
- CHECK_EQUAL( n, 20 );
- }
- {
- // reading 0, u
- unsigned long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 1, "%llu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0ull );
- CHECK_EQUAL( n, 1 );
- }
- {
- // reading -0, u
- unsigned long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 0, "%llu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0ull );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading +0, u
- unsigned long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 3, "%llu%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0ull );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading 9223372036854775807, u
- unsigned long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 100, "%llu%n", &i, &n ), 1 );
- CHECK_FEQUAL( i, 9223372036854775807ull, unsigned long long, "%llu" );
- CHECK_EQUAL( n, 19 );
- }
- {
- // reading +9223372036854775807, u
- unsigned long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 99, "%llu%n", &i, &n ), 1 );
- CHECK_FEQUAL( i, 9223372036854775807ull, unsigned long long, "%llu" );
- CHECK_EQUAL( n, 20 );
- }
- {
- // reading 18446744073709551615, u
- unsigned long long i = 0;
- int n;
- CHECK_EQUAL( sscanf( string + 121, "%llu%n", &i, &n ), 1 );
- CHECK_FEQUAL( i, 18446744073709551615ull, unsigned long long, "%llu" );
- CHECK_EQUAL( n, 20 );
- }
- {
- // reading +18446744073709551615, u
- unsigned long long i = 0;
- int n;
- CHECK_EQUAL( sscanf( string + 120, "%llu%n", &i, &n ), 1 );
- CHECK_FEQUAL( i, 18446744073709551615ull, unsigned long long, "%llu" );
- CHECK_EQUAL( n, 21 );
- }
- {
- // reading 0, i
- signed long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 1, "%lli%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0ll );
- CHECK_EQUAL( n, 1 );
- }
- {
- // reading -0, i
- signed long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 0, "%lli%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0ll );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading +0, i
- signed long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 3, "%lli%n", &i, &n ), 1 );
- CHECK_EQUAL( i, 0ll );
- CHECK_EQUAL( n, 2 );
- }
- {
- // reading -9223372036854775808, i
- signed long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 78, "%lli%n", &i, &n ), 1 );
- CHECK_FEQUAL( i, LLONG_MIN, signed long long, "%lli" ); // should be literal -9223372036854775808ll but GCC balks.
- CHECK_EQUAL( i < 0ll, 1 );
- CHECK_EQUAL( n, 20 );
- }
- {
- // reading 9223372036854775807, i
- signed long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 100, "%lli%n", &i, &n ), 1 );
- CHECK_FEQUAL( i, 9223372036854775807ll, signed long long, "%lli" );
- CHECK_EQUAL( n, 19 );
- }
- {
- // reading +9223372036854775807, i
- signed long long i = -1;
- int n;
- CHECK_EQUAL( sscanf( string + 99, "%lli%n", &i, &n ), 1 );
- CHECK_FEQUAL( i, 9223372036854775807ll, signed long long, "%lli" );
- CHECK_EQUAL( n, 20 );
- }
-}