(t *testing.T)
| 1240 | } |
| 1241 | |
| 1242 | func TestDiffBisect(t *testing.T) { |
| 1243 | type TestCase struct { |
| 1244 | Name string |
| 1245 | |
| 1246 | Time time.Time |
| 1247 | |
| 1248 | Expected []Diff |
| 1249 | } |
| 1250 | |
| 1251 | dmp := New() |
| 1252 | |
| 1253 | for i, tc := range []TestCase{ |
| 1254 | { |
| 1255 | Name: "normal", |
| 1256 | Time: time.Date(9999, time.December, 31, 23, 59, 59, 59, time.UTC), |
| 1257 | |
| 1258 | Expected: []Diff{ |
| 1259 | {DiffDelete, "c"}, |
| 1260 | {DiffInsert, "m"}, |
| 1261 | {DiffEqual, "a"}, |
| 1262 | {DiffDelete, "t"}, |
| 1263 | {DiffInsert, "p"}, |
| 1264 | }, |
| 1265 | }, |
| 1266 | { |
| 1267 | Name: "Negative deadlines count as having infinite time", |
| 1268 | Time: time.Date(0001, time.January, 01, 00, 00, 00, 00, time.UTC), |
| 1269 | |
| 1270 | Expected: []Diff{ |
| 1271 | {DiffDelete, "c"}, |
| 1272 | {DiffInsert, "m"}, |
| 1273 | {DiffEqual, "a"}, |
| 1274 | {DiffDelete, "t"}, |
| 1275 | {DiffInsert, "p"}, |
| 1276 | }, |
| 1277 | }, |
| 1278 | { |
| 1279 | Name: "Timeout", |
| 1280 | // An unambiguously expired deadline. A deadline one |
| 1281 | // nanosecond ahead of setup was unreliable: coarse clocks |
| 1282 | // (Windows) could read the same value back, miss the |
| 1283 | // expiry, and run the bisect to completion. |
| 1284 | Time: time.Now().Add(-time.Second), |
| 1285 | |
| 1286 | Expected: []Diff{ |
| 1287 | {DiffDelete, "cat"}, |
| 1288 | {DiffInsert, "map"}, |
| 1289 | }, |
| 1290 | }, |
| 1291 | } { |
| 1292 | actual := dmp.DiffBisect("cat", "map", tc.Time) |
| 1293 | assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %s", i, tc.Name)) |
| 1294 | } |
| 1295 | |
| 1296 | // Test for invalid UTF-8 sequences |
| 1297 | assert.Equal(t, []Diff{ |
| 1298 | Diff{DiffEqual, "��"}, |
| 1299 | }, dmp.DiffBisect("\xe0\xe5", "\xe0\xe5", time.Now().Add(time.Minute))) |
nothing calls this directly
no test coverage detected