Skip to content

Commit 20dc4fa

Browse files
ShoshinNikitaharry-hov
authored andcommitted
add test case for the issue sergi#115
1 parent 090039d commit 20dc4fa

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

diffmatchpatch/diff_test.go

+35-7
Original file line numberDiff line numberDiff line change
@@ -1419,16 +1419,12 @@ func TestDiffMainWithTimeout(t *testing.T) {
14191419
}
14201420

14211421
func TestDiffMainWithCheckLines(t *testing.T) {
1422+
// Test cases must be at least 100 chars long to pass the cutoff.
14221423
type TestCase struct {
14231424
Text1 string
14241425
Text2 string
14251426
}
1426-
1427-
dmp := New()
1428-
dmp.DiffTimeout = 0
1429-
1430-
// Test cases must be at least 100 chars long to pass the cutoff.
1431-
for i, tc := range []TestCase{
1427+
tests := []TestCase{
14321428
{
14331429
"1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n",
14341430
"abcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\n",
@@ -1441,7 +1437,39 @@ func TestDiffMainWithCheckLines(t *testing.T) {
14411437
"1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n",
14421438
"abcdefghij\n1234567890\n1234567890\n1234567890\nabcdefghij\n1234567890\n1234567890\n1234567890\nabcdefghij\n1234567890\n1234567890\n1234567890\nabcdefghij\n",
14431439
},
1444-
} {
1440+
}
1441+
// Add test case for the issue #115
1442+
func() {
1443+
const before = `package main
1444+
1445+
import (
1446+
"fmt"
1447+
)
1448+
1449+
/*
1450+
func upload(c echo.Context) error {
1451+
if err := r.ParseForm(); err != nil {
1452+
fmt.Fprintf(w, "ParseForm() err: %v", err)
1453+
return
1454+
}
1455+
fmt.Fprintf(w, "POST request successful")
1456+
path_ver := r.FormValue("path_ver")
1457+
ukclin_ver := r.FormValue("ukclin_ver")
1458+
1459+
fmt.Fprintf(w, "Name = %s\n", path_ver)
1460+
fmt.Fprintf(w, "Address = %s\n", ukclin_ver)
1461+
}
1462+
*/
1463+
`
1464+
after := strings.ReplaceAll(before, "\n", "\r\n")
1465+
1466+
tests = append(tests, TestCase{Text1: before, Text2: after})
1467+
}()
1468+
1469+
dmp := New()
1470+
dmp.DiffTimeout = 0
1471+
1472+
for i, tc := range tests {
14451473
resultWithoutCheckLines := dmp.DiffMain(tc.Text1, tc.Text2, false)
14461474
resultWithCheckLines := dmp.DiffMain(tc.Text1, tc.Text2, true)
14471475

0 commit comments

Comments
 (0)