func showDiffLine(del, ins string) { delT, insT := tm.LineToTokens(del), tm.LineToTokens(ins) matA, matB := tm.MatchTokens(delT, insT) showDelTokens(delT, matA, insT) showInsTokens(insT, matB, delT) }
func TestDiffLine(t *testing.T) { delT := tm.LineToTokens("func g(src string, dst string) error {") insT := tm.LineToTokens("func (m *monitor) g(gsp string) error {") _, matA, matB := ed.EditDistanceFFull(len(delT), len(insT), func(iA, iB int) int { if delT[iA] == insT[iB] { return 0 } // if return len(delT[iA]) + len(insT[iB]) + 1 }, func(iA int) int { if delT[iA] == " " { return 0 } // if return len(delT[iA]) }, func(iB int) int { if insT[iB] == " " { return 0 } // if return len(insT[iB]) }) ShowDelTokens(delT, matA, insT) ShowInsTokens(insT, matB, delT) }