@@ -77,6 +77,8 @@ class TestIO : public TestFixture {
7777 TEST_CASE (testPrintfParenthesis); // #8489
7878 TEST_CASE (testStdDistance); // #10304
7979 TEST_CASE (testParameterPack); // #11289
80+
81+ TEST_CASE (testDefaultSignInt); // #13363
8082 }
8183
8284 struct CheckOptions
@@ -85,6 +87,7 @@ class TestIO : public TestFixture {
8587 bool inconclusive = false ;
8688 bool portability = false ;
8789 Platform::Type platform = Platform::Type::Unspecified;
90+ char defaultSign = ' \0 ' ;
8891 bool onlyFormatStr = false ;
8992 bool cpp = true ;
9093 };
@@ -96,6 +99,7 @@ class TestIO : public TestFixture {
9699 settings1.severity .setEnabled (Severity::portability, options.portability );
97100 settings1.certainty .setEnabled (Certainty::inconclusive, options.inconclusive );
98101 PLATFORM (settings1.platform , options.platform );
102+ settings1.platform .defaultSign = options.defaultSign ;
99103
100104 // Tokenize..
101105 SimpleTokenizer tokenizer (settings1, *this );
@@ -4933,6 +4937,22 @@ class TestIO : public TestFixture {
49334937 " }\n " );
49344938 ASSERT_EQUALS (" " , errout_str ());
49354939 }
4940+
4941+ // TODO: we need to run big tests with a platform that has unsigned chars
4942+ void testDefaultSignInt () { // #13363
4943+ // Platform::defaultSign should only affect char
4944+ const char code[] =
4945+ " void f() {\n "
4946+ " double d = 1\n ;"
4947+ " printf(\" %i\" , int(d));\n "
4948+ " }\n " ;
4949+ check (code);
4950+ ASSERT_EQUALS (" " , errout_str ());
4951+ check (code, dinit (CheckOptions, $.defaultSign = ' s' ));
4952+ ASSERT_EQUALS (" " , errout_str ());
4953+ check (code, dinit (CheckOptions, $.defaultSign = ' u' ));
4954+ ASSERT_EQUALS (" " , errout_str ());
4955+ }
49364956};
49374957
49384958REGISTER_TEST (TestIO)
0 commit comments