Skip to content

Commit 173443b

Browse files
committed
Add test case for eof in __VA_OPT__
1 parent 448a22e commit 173443b

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

test.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,33 @@ static void define_va_opt_6()
984984
toString(outputList));
985985
}
986986

987+
static void define_va_opt_7()
988+
{
989+
// eof in __VA_OPT__
990+
const char code1[] = "#define err(...) __VA_OPT__";
991+
992+
simplecpp::OutputList outputList;
993+
ASSERT_EQUALS("", preprocess(code1, &outputList));
994+
ASSERT_EQUALS("file0,1,syntax_error,Failed to parse #define, Missing opening parenthesis for __VA_OPT__\n",
995+
toString(outputList));
996+
997+
outputList.clear();
998+
999+
const char code2[] = "#define err(...) __VA_OPT__(";
1000+
1001+
ASSERT_EQUALS("", preprocess(code2, &outputList));
1002+
ASSERT_EQUALS("file0,1,syntax_error,Failed to parse #define, Missing closing parenthesis for __VA_OPT__\n",
1003+
toString(outputList));
1004+
1005+
outputList.clear();
1006+
1007+
const char code3[] = "#define err(...) __VA_OPT__(x";
1008+
1009+
ASSERT_EQUALS("", preprocess(code3, &outputList));
1010+
ASSERT_EQUALS("file0,1,syntax_error,Failed to parse #define, Missing closing parenthesis for __VA_OPT__\n",
1011+
toString(outputList));
1012+
}
1013+
9871014
static void define_ifdef()
9881015
{
9891016
const char code[] = "#define A(X) X\n"
@@ -3076,6 +3103,7 @@ int main(int argc, char **argv)
30763103
TEST_CASE(define_va_opt_4);
30773104
TEST_CASE(define_va_opt_5);
30783105
TEST_CASE(define_va_opt_6);
3106+
TEST_CASE(define_va_opt_7);
30793107

30803108
TEST_CASE(pragma_backslash); // multiline pragma directive
30813109

0 commit comments

Comments
 (0)