Skip to content

Commit e83de4f

Browse files
committed
test.cpp: added tests for #40
1 parent e37c055 commit e83de4f

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

test.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,44 @@ static void define21() // #66
857857
"foo ( 1 , ( ( a ) ) + 1 ) ;", preprocess(code));
858858
}
859859

860+
static void define22() // #40
861+
{
862+
const char code[] = "#define COUNTER_NAME(NAME, ...) NAME##Count\n"
863+
"#define COMMA ,\n"
864+
"\n"
865+
"#define DECLARE_COUNTERS(LIST) unsigned long LIST(COUNTER_NAME, COMMA);\n"
866+
"\n"
867+
"#define ACTUAL_LIST(FUNCTION, SEPARATOR) \\\n"
868+
"FUNCTION(event1, int, foo) SEPARATOR \\\n"
869+
"FUNCTION(event2, char, bar)\n"
870+
"\n"
871+
"DECLARE_COUNTERS(ACTUAL_LIST)\n";
872+
ASSERT_EQUALS("\n"
873+
"\n"
874+
"\n"
875+
"\n"
876+
"\n"
877+
"\n"
878+
"\n"
879+
"\n"
880+
"\n"
881+
"unsigned long event1Count , event2Count ;", preprocess(code));
882+
}
883+
884+
static void define23() // #40
885+
{
886+
const char code[] = "#define COMMA ,\n"
887+
"#define MULTI(SEPARATOR) A SEPARATOR B\n"
888+
"\n"
889+
"#define VARS MULTI(COMMA)\n"
890+
"unsigned VARS;\n";
891+
ASSERT_EQUALS("\n"
892+
"\n"
893+
"\n"
894+
"\n"
895+
"unsigned A , B ;", preprocess(code));
896+
}
897+
860898

861899
static void define_invalid_1()
862900
{
@@ -3839,6 +3877,8 @@ static void runTests(int argc, char **argv, Input input)
38393877
TEST_CASE(define19); // #124
38403878
TEST_CASE(define20); // #113
38413879
TEST_CASE(define21); // #66
3880+
TEST_CASE(define22); // #40
3881+
TEST_CASE(define23); // #40
38423882
TEST_CASE(define_invalid_1);
38433883
TEST_CASE(define_invalid_2);
38443884
TEST_CASE(define_define_1);

0 commit comments

Comments
 (0)