Skip to content

Commit 3e90a3b

Browse files
Add tests for escaped delimiters
1 parent 03c2e62 commit 3e90a3b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

search-replace_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ func TestReplace(t *testing.T) {
135135
// Generally recovering from a 'syntax error' of a parser - which is what we have here, due to the wrong byte size for a8c.com,
136136
// is probably impossible. It destroys all offsets and suddenly we lose track of where the tokenization is at.
137137
// Self-recovery is prone to error, and might grab the token entrance at the wrong place.
138-
// Also, the PHP version of search and replace does not support this either.
139138
//{
140139
// testName: "only fix updated strings, with bad data in between",
141140
//
@@ -202,6 +201,20 @@ func TestReplace(t *testing.T) {
202201
in: []byte(`s:18:\"\\a\\b\\c\\d\\e\\f\\g\\h\";\";`),
203202
out: []byte(`s:14:\"\\a\\b\\x\\f\\g\\h\";\";`),
204203
},
204+
{
205+
testName: "escaped delimiters",
206+
from: []byte(`hello`),
207+
to: []byte(`helloworld`),
208+
in: []byte(`('s:34:\"\";\";\";\";\";\\\";\\\";\\\"; hello \\\\\";\\\\\";\";')`),
209+
out: []byte(`('s:39:\"\";\";\";\";\";\\\";\\\";\\\"; helloworld \\\\\";\\\\\";\";')`),
210+
},
211+
{
212+
testName: "mydumper escaped delimiters",
213+
from: []byte(`hello`),
214+
to: []byte(`helloworld`),
215+
in: []byte(`("s:34:\"\";\";\";\";\";\\\";\\\";\\\"; hello \\\\\";\\\\\";\";")`),
216+
out: []byte(`("s:39:\"\";\";\";\";\";\\\";\\\";\\\"; helloworld \\\\\";\\\\\";\";")`),
217+
},
205218
{
206219
testName: "search and replace with different lengths",
207220

0 commit comments

Comments
 (0)