Skip to content

Commit f57d201

Browse files
committed
add test
1 parent 439ac67 commit f57d201

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

test.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3782,6 +3782,31 @@ static void tokenMacro5()
37823782
ASSERT_EQUALS("SET_BPF_JUMP", tok->macro);
37833783
}
37843784

3785+
static void tokenMacro6()
3786+
{
3787+
const char code[] = "#define FILE() __FILE__\n"
3788+
"#define LINE() __LINE__\n"
3789+
"#define COUNTER() __COUNTER__\n"
3790+
"FILE()\n"
3791+
"LINE()\n"
3792+
"COUNTER()\n";
3793+
std::vector<std::string> files;
3794+
simplecpp::FileDataCache cache;
3795+
simplecpp::TokenList tokenList(files);
3796+
const simplecpp::TokenList rawtokens = makeTokenList(code,files);
3797+
simplecpp::preprocess(tokenList, rawtokens, files, cache, simplecpp::DUI());
3798+
const simplecpp::Token *tok;
3799+
3800+
tok = tokenList.cfront();
3801+
ASSERT_EQUALS("__FILE__", tok->macro);
3802+
3803+
tok = tok->next;
3804+
ASSERT_EQUALS("__LINE__", tok->macro);
3805+
3806+
tok = tok->next;
3807+
ASSERT_EQUALS("__COUNTER__", tok->macro);
3808+
}
3809+
37853810
static void undef()
37863811
{
37873812
const char code[] = "#define A\n"
@@ -4781,6 +4806,7 @@ static void runTests(int argc, char **argv, Input input)
47814806
TEST_CASE(tokenMacro3);
47824807
TEST_CASE(tokenMacro4);
47834808
TEST_CASE(tokenMacro5);
4809+
TEST_CASE(tokenMacro6);
47844810

47854811
TEST_CASE(undef);
47864812

0 commit comments

Comments
 (0)