Skip to content

Commit 9e52f28

Browse files
geoffw0jketema
authored andcommitted
C++: Test edge cases for string literal locations.
1 parent 0ab9454 commit 9e52f28

4 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎cpp/ql/test/library-tests/regex/locations.expected‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,4 @@
6363
| regexp.cpp:123:41:123:44 | a\\nc | regexp.cpp | 123 | 41 | 123 | 44 |
6464
| regexp.cpp:124:25:124:28 | a\\nc | regexp.cpp | 124 | 25 | 124 | 28 |
6565
| regexp.cpp:125:29:125:32 | a\\nc | regexp.cpp | 125 | 29 | 125 | 32 |
66+
| regexp.cpp:130:29:130:32 | abc1 | regexp.cpp | 130 | 29 | 130 | 32 |

‎cpp/ql/test/library-tests/regex/parse.expected‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#-----| [RegExpConstant, RegExpNormalChars] xabc3x
2+
3+
#-----| [RegExpConstant, RegExpNormalChars] abc2
4+
15
regexp.cpp:
26
# 19| [RegExpConstant, RegExpNormalChars] abc
37

@@ -647,3 +651,5 @@ regexp.cpp:
647651
# 125| [RegExpConstant, RegExpEscape] \n
648652

649653
# 125| [RegExpConstant, RegExpNormalChars] c
654+
655+
# 130| [RegExpConstant, RegExpNormalChars] abc1

‎cpp/ql/test/library-tests/regex/regexp.cpp‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,10 @@ std::basic_regex<char16_t> r_loc_uR(uR"(a\nc)");
123123
std::basic_regex<char32_t> r_loc_UR(UR"(a\nc)");
124124
std::regex r_loc_Rx(R"x(a\nc)x");
125125
std::regex r_loc_Rfoo(R"foo(a\nc)foo");
126+
127+
// Composite and stringified string literals
128+
#define STRINGIFY(str) #str
129+
#define WRAP(str) "x" #str "x"
130+
std::regex r_loc_composite("ab" "c1");
131+
std::regex r_loc_macro1(STRINGIFY(abc2));
132+
std::regex r_loc_macro2(WRAP(abc3));

‎cpp/ql/test/library-tests/regex/regexp.expected‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ groupNumber
44
| regexp.cpp:58:20:58:27 | (a\|b\|cd) | 1 |
55
| regexp.cpp:62:21:62:24 | (a+) | 1 |
66
term
7+
| file://:0:0:0:0 | abc2 | RegExpConstant,RegExpNormalChars |
8+
| file://:0:0:0:0 | xabc3x | RegExpConstant,RegExpNormalChars |
79
| regexp.cpp:19:19:19:21 | abc | RegExpConstant,RegExpNormalChars |
810
| regexp.cpp:22:20:22:20 | a | RegExpConstant,RegExpNormalChars |
911
| regexp.cpp:22:20:22:21 | a* | RegExpStar |
@@ -242,7 +244,10 @@ term
242244
| regexp.cpp:125:29:125:32 | a\\nc | RegExpSequence |
243245
| regexp.cpp:125:30:125:31 | \\n | RegExpConstant,RegExpEscape |
244246
| regexp.cpp:125:32:125:32 | c | RegExpConstant,RegExpNormalChars |
247+
| regexp.cpp:130:29:130:32 | abc1 | RegExpConstant,RegExpNormalChars |
245248
regExpNormalCharValue
249+
| file://:0:0:0:0 | abc2 | abc2 |
250+
| file://:0:0:0:0 | xabc3x | xabc3x |
246251
| regexp.cpp:19:19:19:21 | abc | abc |
247252
| regexp.cpp:22:20:22:20 | a | a |
248253
| regexp.cpp:22:22:22:22 | b | b |
@@ -366,3 +371,4 @@ regExpNormalCharValue
366371
| regexp.cpp:125:29:125:29 | a | a |
367372
| regexp.cpp:125:30:125:31 | \\n | \n |
368373
| regexp.cpp:125:32:125:32 | c | c |
374+
| regexp.cpp:130:29:130:32 | abc1 | abc1 |

0 commit comments

Comments
 (0)