Add tests for concatenate_string_literals

pull/3744/head
Christoph Behle 7 years ago committed by Nirbheek Chauhan
parent 626b0bcb05
commit b19b714f37
  1. 15
      test cases/common/140 get define/concat.h
  2. 14
      test cases/common/140 get define/meson.build

@ -7,6 +7,17 @@
#define TEST_VERSION_STR \
TEST_STRINGIFY(TEST_VERSION_MAJOR) \
"." TEST_STRINGIFY(TEST_VERSION_MINOR) "." TEST_STRINGIFY(TEST_VERSION_BUGFIX)
"." TEST_STRINGIFY(TEST_VERSION_MINOR) "." TEST_STRINGIFY( \
TEST_VERSION_BUGFIX)
// TEST_VERSION_STR "6" "." "0" "." "0"
#define TEST_CONCAT_1 \
"ab" \
"cd" \
"ef"
#define TEST_CONCAT_2 1
#define TEST_CONCAT_3 1 2 3
#define TEST_CONCAT_4 "ab" 1 "cd"
#define TEST_CONCAT_5 \
"ab\"" \
"cd"
#define TEST_CONCAT_6 "ab\" \"cd"

@ -84,4 +84,18 @@ foreach lang : ['c', 'cpp']
have = cc.get_define('TEST_VERSION_STR',
prefix : '#include <concat.h>', include_directories: include_directories('.'), concatenate_string_literals: true)
assert(have == '"6.0.0"', 'TEST_VERSION_STR value is "@0@" instead of ""6.0.0""'.format(have))
concat_examples = {
'TEST_CONCAT_1': '"abcdef"',
'TEST_CONCAT_2': '1',
'TEST_CONCAT_3': '1 2 3',
'TEST_CONCAT_4': '"ab" 1 "cd"',
'TEST_CONCAT_5': '"ab\"cd"',
'TEST_CONCAT_6': '"ab\" \"cd"',
}
foreach def,expected : concat_examples
have = cc.get_define(def,
prefix : '#include <concat.h>', include_directories: include_directories('.'), concatenate_string_literals: true)
assert(have == expected, '@0@ value is "@1@" instead of "@2@"'.format(def, have, expected))
endforeach
endforeach

Loading…
Cancel
Save