-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathld_test.go
More file actions
32 lines (26 loc) · 930 Bytes
/
Copy pathld_test.go
File metadata and controls
32 lines (26 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"testing"
)
func TestIgnoreIndentationLeavesSnippetsAtDistanceZero(t *testing.T) {
expected := "func main() {\n\tfmt.Println(\"hi\")\n}"
typedWithSpaces := "func main() {\n fmt.Println(\"hi\")\n}"
typedFlat := "func main() {\nfmt.Println(\"hi\")\n}\n\n"
for _, actual := range []string{expected, typedWithSpaces, typedFlat} {
if distance := Ld(IgnoreIndentation(actual), IgnoreIndentation(expected)); distance != 0 {
t.Errorf("Ld(%q) = %d, want 0", actual, distance)
}
}
}
func TestIgnoreIndentationKeepsRealDifferences(t *testing.T) {
expected := "a\n\tb"
actual := "a\n\tc"
if distance := Ld(IgnoreIndentation(actual), IgnoreIndentation(expected)); distance != 1 {
t.Errorf("Ld = %d, want 1", distance)
}
}
func TestIgnoreIndentationKeepsLineBreaks(t *testing.T) {
if got := IgnoreIndentation(" a \n\n\t b\t"); got != "a\nb" {
t.Errorf("got %q, want %q", got, "a\nb")
}
}