@@ -77,6 +77,8 @@ class TestIO : public TestFixture {
77
77
TEST_CASE(testPrintfParenthesis); // #8489
78
78
TEST_CASE(testStdDistance); // #10304
79
79
TEST_CASE(testParameterPack); // #11289
80
+
81
+ TEST_CASE(testDefaultSignInt); // #13363
80
82
}
81
83
82
84
struct CheckOptions
@@ -85,6 +87,7 @@ class TestIO : public TestFixture {
85
87
bool inconclusive = false;
86
88
bool portability = false;
87
89
Platform::Type platform = Platform::Type::Unspecified;
90
+ char defaultSign = '\0';
88
91
bool onlyFormatStr = false;
89
92
bool cpp = true;
90
93
};
@@ -96,6 +99,7 @@ class TestIO : public TestFixture {
96
99
settings1.severity.setEnabled(Severity::portability, options.portability);
97
100
settings1.certainty.setEnabled(Certainty::inconclusive, options.inconclusive);
98
101
PLATFORM(settings1.platform, options.platform);
102
+ settings1.platform.defaultSign = options.defaultSign;
99
103
100
104
// Tokenize..
101
105
SimpleTokenizer tokenizer(settings1, *this);
@@ -4933,6 +4937,22 @@ class TestIO : public TestFixture {
4933
4937
"}\n");
4934
4938
ASSERT_EQUALS("", errout_str());
4935
4939
}
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
+ }
4936
4956
};
4937
4957
4938
4958
REGISTER_TEST(TestIO)
0 commit comments