MCPcopy Create free account
hub / github.com/sergi/go-diff / TestDiffBisect

Function TestDiffBisect

diffmatchpatch/diff_test.go:1218–1272  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1216}
1217
1218func TestDiffBisect(t *testing.T) {
1219 type TestCase struct {
1220 Name string
1221
1222 Time time.Time
1223
1224 Expected []Diff
1225 }
1226
1227 dmp := New()
1228
1229 for i, tc := range []TestCase{
1230 {
1231 Name: "normal",
1232 Time: time.Date(9999, time.December, 31, 23, 59, 59, 59, time.UTC),
1233
1234 Expected: []Diff{
1235 {DiffDelete, "c"},
1236 {DiffInsert, "m"},
1237 {DiffEqual, "a"},
1238 {DiffDelete, "t"},
1239 {DiffInsert, "p"},
1240 },
1241 },
1242 {
1243 Name: "Negative deadlines count as having infinite time",
1244 Time: time.Date(0001, time.January, 01, 00, 00, 00, 00, time.UTC),
1245
1246 Expected: []Diff{
1247 {DiffDelete, "c"},
1248 {DiffInsert, "m"},
1249 {DiffEqual, "a"},
1250 {DiffDelete, "t"},
1251 {DiffInsert, "p"},
1252 },
1253 },
1254 {
1255 Name: "Timeout",
1256 Time: time.Now().Add(time.Nanosecond),
1257
1258 Expected: []Diff{
1259 {DiffDelete, "cat"},
1260 {DiffInsert, "map"},
1261 },
1262 },
1263 } {
1264 actual := dmp.DiffBisect("cat", "map", tc.Time)
1265 assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %s", i, tc.Name))
1266 }
1267
1268 // Test for invalid UTF-8 sequences
1269 assert.Equal(t, []Diff{
1270 Diff{DiffEqual, "��"},
1271 }, dmp.DiffBisect("\xe0\xe5", "\xe0\xe5", time.Now().Add(time.Minute)))
1272}
1273
1274func TestDiffMain(t *testing.T) {
1275 type TestCase struct {

Callers

nothing calls this directly

Calls 2

NewFunction · 0.85
DiffBisectMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…