Commit 03b6858
committed
Fix test framework to compare strings with embedded nulls
The TEST_EQUIV comparison used strcmp on ast_get_print(), which stops
at the first null byte. This meant any test comparing string literals
with embedded nulls (\x00) would silently pass even if the content
after the null differed — strcmp sees both sides as equal at the
truncation point.
Add a TK_STRING special case in compare_asts that uses ast_name_len
and memcmp for length-aware comparison. This is needed to properly
test compile-time folding of strings containing embedded nulls.
Add StringConcatEmbeddedNull test verifying that "ab\x00cd" + "ef"
folds to "ab\x00cdef" with the correct 7-byte length.1 parent 2c6bbb8 commit 03b6858
2 files changed
+33
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2228 | 2228 | | |
2229 | 2229 | | |
2230 | 2230 | | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
158 | 172 | | |
159 | 173 | | |
160 | 174 | | |
| |||
0 commit comments