Skip to content

Commit c531b0f

Browse files
committed
test.cpp: added tests for #40
1 parent d70570c commit c531b0f

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
@@ -829,6 +829,44 @@ static void define21() // #66
829829
"foo ( 1 , ( ( a ) ) + 1 ) ;", preprocess(code));
830830
}
831831

832+
static void define22() // #40
833+
{
834+
const char code[] = "#define COUNTER_NAME(NAME, ...) NAME##Count\n"
835+
"#define COMMA ,\n"
836+
"\n"
837+
"#define DECLARE_COUNTERS(LIST) unsigned long LIST(COUNTER_NAME, COMMA);\n"
838+
"\n"
839+
"#define ACTUAL_LIST(FUNCTION, SEPARATOR) \\\n"
840+
"FUNCTION(event1, int, foo) SEPARATOR \\\n"
841+
"FUNCTION(event2, char, bar)\n"
842+
"\n"
843+
"DECLARE_COUNTERS(ACTUAL_LIST)\n";
844+
ASSERT_EQUALS("\n"
845+
"\n"
846+
"\n"
847+
"\n"
848+
"\n"
849+
"\n"
850+
"\n"
851+
"\n"
852+
"\n"
853+
"unsigned long event1Count , event2Count ;", preprocess(code));
854+
}
855+
856+
static void define23() // #40
857+
{
858+
const char code[] = "#define COMMA ,\n"
859+
"#define MULTI(SEPARATOR) A SEPARATOR B\n"
860+
"\n"
861+
"#define VARS MULTI(COMMA)\n"
862+
"unsigned VARS;\n";
863+
ASSERT_EQUALS("\n"
864+
"\n"
865+
"\n"
866+
"\n"
867+
"unsigned A , B ;", preprocess(code));
868+
}
869+
832870

833871
static void define_invalid_1()
834872
{
@@ -3809,6 +3847,8 @@ int main(int argc, char **argv)
38093847
TEST_CASE(define19); // #124
38103848
TEST_CASE(define20); // #113
38113849
TEST_CASE(define21); // #66
3850+
TEST_CASE(define22); // #40
3851+
TEST_CASE(define23); // #40
38123852
TEST_CASE(define_invalid_1);
38133853
TEST_CASE(define_invalid_2);
38143854
TEST_CASE(define_define_1);

0 commit comments

Comments
 (0)