Skip to content

Commit 6771527

Browse files
committed
add tests
1 parent 46d9197 commit 6771527

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

test/testpreprocessor.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ class TestPreprocessor : public TestFixture {
238238
TEST_CASE(predefine5); // automatically define __cplusplus
239239
TEST_CASE(predefine6); // automatically define __STDC_VERSION__
240240

241+
242+
TEST_CASE(strictAnsi);
243+
241244
TEST_CASE(invalidElIf); // #2942 segfault
242245

243246
// Preprocessor::getConfigs
@@ -2036,6 +2039,23 @@ class TestPreprocessor : public TestFixture {
20362039
ASSERT_EQUALS("", PreprocessorHelper::getcode(settings0, *this, code, "", "test.cpp"));
20372040
}
20382041

2042+
void strictAnsi() {
2043+
const char code[] = "#ifdef __STRICT_ANSI__\n123\n#endif";
2044+
Settings settings;
2045+
2046+
settings.standards.setStd("gnu99");
2047+
ASSERT_EQUALS("", PreprocessorHelper::getcode(settings, *this, code, "", "test.c"));
2048+
2049+
settings.standards.setStd("c99");
2050+
ASSERT_EQUALS("\n123", PreprocessorHelper::getcode(settings, *this, code, "", "test.c"));
2051+
2052+
settings.standards.setStd("gnu++11");
2053+
ASSERT_EQUALS("", PreprocessorHelper::getcode(settings, *this, code, "", "test.cpp"));
2054+
2055+
settings.standards.setStd("c++11");
2056+
ASSERT_EQUALS("\n123", PreprocessorHelper::getcode(settings, *this, code, "", "test.cpp"));
2057+
}
2058+
20392059
void invalidElIf() {
20402060
// #2942 - segfault
20412061
const char code[] = "#elif (){\n";

0 commit comments

Comments
 (0)