Skip to content

Commit 3d952c0

Browse files
committed
Fixes #49: All test suite checks using long-long specifiers are now guarded by #if PRINTF_SUPPORT_LONG_LONG, and in a few configurations, all checks pass both with and without that flag turned on. Any other failures can get their own issues...
1 parent 6dea954 commit 3d952c0

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

test/test_suite.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ TEST_CASE("# flag - non-standard format", "[]" ) {
412412
}
413413
#endif
414414

415+
#if PRINTF_SUPPORT_LONG_LONG
415416
TEST_CASE("# flag with long-long", "[]" ) {
416417
char buffer[100];
417418
PRINTING_CHECK("0", ==, test::sprintf_, buffer, "%#llo", (long long) 0 );
@@ -432,13 +433,14 @@ TEST_CASE("# flag with long-long", "[]" ) {
432433
PRINTING_CHECK("0x0000614e", ==, test::sprintf_, buffer, "%#.8llx", (long long) 0x614e );
433434
}
434435

436+
435437
#ifdef TEST_WITH_NON_STANDARD_FORMAT_STRINGS
436438
TEST_CASE("# flag with long-long - non-standard format", "[]" ) {
437439
char buffer[100];
438440
PRINTING_CHECK("0b110", ==, test::sprintf_, buffer, "%#llb", (long long) 6);
439441
}
440442
#endif
441-
443+
#endif // PRINTF_SUPPORT_LONG_LONG
442444

443445
TEST_CASE("specifier", "[]" ) {
444446
char buffer[100];
@@ -502,7 +504,9 @@ TEST_CASE("width 20", "[]" ) {
502504
PRINTING_CHECK(" EDCB5433", ==, test::sprintf_, buffer, "%20X", 3989525555U);
503505
PRINTING_CHECK(" 0", ==, test::sprintf_, buffer, "%20X", 0);
504506
PRINTING_CHECK(" 0", ==, test::sprintf_, buffer, "%20X", 0U);
507+
#if PRINTF_SUPPORT_LONG_LONG
505508
PRINTING_CHECK(" 0", ==, test::sprintf_, buffer, "%20llX", 0ULL);
509+
#endif
506510
PRINTING_CHECK(" x", ==, test::sprintf_, buffer, "%20c", 'x');
507511
}
508512

@@ -922,20 +926,26 @@ TEST_CASE("types", "[]" ) {
922926
PRINTING_CHECK("30", ==, test::sprintf_, buffer, "%li", 30L);
923927
PRINTING_CHECK("-2147483647", ==, test::sprintf_, buffer, "%li", -2147483647L);
924928
PRINTING_CHECK("2147483647", ==, test::sprintf_, buffer, "%li", 2147483647L);
929+
#if PRINTF_SUPPORT_LONG_LONG
925930
PRINTING_CHECK("30", ==, test::sprintf_, buffer, "%lli", 30LL);
926931
PRINTING_CHECK("-9223372036854775807", ==, test::sprintf_, buffer, "%lli", -9223372036854775807LL);
927932
PRINTING_CHECK("9223372036854775807", ==, test::sprintf_, buffer, "%lli", 9223372036854775807LL);
933+
#endif
928934
PRINTING_CHECK("100000", ==, test::sprintf_, buffer, "%lu", 100000L);
929935
PRINTING_CHECK("4294967295", ==, test::sprintf_, buffer, "%lu", 0xFFFFFFFFL);
936+
#if PRINTF_SUPPORT_LONG_LONG
930937
PRINTING_CHECK("281474976710656", ==, test::sprintf_, buffer, "%llu", 281474976710656LLU);
931938
PRINTING_CHECK("18446744073709551615", ==, test::sprintf_, buffer, "%llu", 18446744073709551615LLU);
939+
#endif
932940
PRINTING_CHECK("2147483647", ==, test::sprintf_, buffer, "%zu", (size_t)2147483647UL);
933941
PRINTING_CHECK("2147483647", ==, test::sprintf_, buffer, "%zd", (size_t)2147483647UL);
934942
PRINTING_CHECK("-2147483647", ==, test::sprintf_, buffer, "%zi", (ssize_t)-2147483647L);
935943
PRINTING_CHECK("165140", ==, test::sprintf_, buffer, "%o", 60000);
936944
PRINTING_CHECK("57060516", ==, test::sprintf_, buffer, "%lo", 12345678L);
937945
PRINTING_CHECK("12345678", ==, test::sprintf_, buffer, "%lx", 0x12345678L);
946+
#if PRINTF_SUPPORT_LONG_LONG
938947
PRINTING_CHECK("1234567891234567", ==, test::sprintf_, buffer, "%llx", 0x1234567891234567LLU);
948+
#endif
939949
PRINTING_CHECK("abcdefab", ==, test::sprintf_, buffer, "%lx", 0xabcdefabL);
940950
PRINTING_CHECK("ABCDEFAB", ==, test::sprintf_, buffer, "%lX", 0xabcdefabL);
941951
PRINTING_CHECK("v", ==, test::sprintf_, buffer, "%c", 'v');
@@ -1133,11 +1143,13 @@ TEST_CASE("extremal signed integer values", "[]" ) {
11331143
std::sprintf(expected, "%ld", std::numeric_limits<long int>::max());
11341144
PRINTING_CHECK(expected, ==, test::sprintf_, buffer, "%ld", std::numeric_limits<long int>::max());
11351145

1146+
#if PRINTF_SUPPORT_LONG_LONG
11361147
std::sprintf(expected, "%lld", std::numeric_limits<long long int>::min());
11371148
PRINTING_CHECK(expected, ==, test::sprintf_, buffer, "%lld", std::numeric_limits<long long int>::min());
11381149

11391150
std::sprintf(expected, "%lld", std::numeric_limits<long long int>::max());
11401151
PRINTING_CHECK(expected, ==, test::sprintf_, buffer, "%lld", std::numeric_limits<long long int>::max());
1152+
#endif
11411153
}
11421154

11431155
TEST_CASE("extremal unsigned integer values", "[]" ) {
@@ -1156,8 +1168,10 @@ TEST_CASE("extremal unsigned integer values", "[]" ) {
11561168
std::sprintf(expected, "%lu", std::numeric_limits<long unsigned>::max());
11571169
PRINTING_CHECK(expected, ==, test::sprintf_, buffer, "%lu", std::numeric_limits<long unsigned>::max());
11581170

1171+
#if PRINTF_SUPPORT_LONG_LONG
11591172
std::sprintf(expected, "%llu", std::numeric_limits<long long unsigned>::max());
11601173
PRINTING_CHECK(expected, ==, test::sprintf_, buffer, "%llu", std::numeric_limits<long long unsigned>::max());
1174+
#endif
11611175
}
11621176

11631177

0 commit comments

Comments
 (0)