commit 5cb1bbe

Hubert Hirtz  ·  2021-05-25 16:37:11 +0000 UTC
parent 2b3c8d2
Fix ui tests
2 files changed,  +14, -14
+2, -2
 1@@ -6,7 +6,7 @@ import (
 2 )
 3 
 4 func assertSplitPoints(t *testing.T, body string, expected []point) {
 5-	l := Line{body: body}
 6+	l := Line{Body: body}
 7 	l.computeSplitPoints()
 8 
 9 	if len(l.splitPoints) != len(expected) {
10@@ -71,7 +71,7 @@ func showSplit(s string, nls []int) string {
11 }
12 
13 func assertNewLines(t *testing.T, body string, width int, expected int) {
14-	l := Line{body: body}
15+	l := Line{Body: body}
16 	l.computeSplitPoints()
17 
18 	actual := l.NewLines(width)
+12, -12
 1@@ -2,21 +2,21 @@ package ui
 2 
 3 import "testing"
 4 
 5-var hell editor = editor{
 6-	text:      []rune{'h', 'e', 'l', 'l'},
 7+var hell Editor = Editor{
 8+	text:      [][]rune{[]rune{'h', 'e', 'l', 'l'}},
 9 	textWidth: []int{0, 1, 2, 3, 4},
10 	cursorIdx: 4,
11 	offsetIdx: 0,
12 	width:     5,
13 }
14 
15-func assertEditorEq(t *testing.T, actual, expected editor) {
16+func assertEditorEq(t *testing.T, actual, expected Editor) {
17 	if len(actual.text) != len(expected.text) {
18 		t.Errorf("expected text len to be %d, got %d\n", len(expected.text), len(actual.text))
19 	} else {
20 		for i := 0; i < len(actual.text); i++ {
21-			a := actual.text[i]
22-			e := expected.text[i]
23+			a := actual.text[0][i]
24+			e := expected.text[0][i]
25 
26 			if a != e {
27 				t.Errorf("expected rune #%d to be '%c', got '%c'\n", i, e, a)
28@@ -51,10 +51,10 @@ func assertEditorEq(t *testing.T, actual, expected editor) {
29 }
30 
31 func TestOneLetter(t *testing.T) {
32-	e := newEditor(5)
33+	e := NewEditor(5, nil)
34 	e.PutRune('h')
35-	assertEditorEq(t, e, editor{
36-		text:      []rune{'h'},
37+	assertEditorEq(t, e, Editor{
38+		text:      [][]rune{[]rune{'h'}},
39 		textWidth: []int{0, 1},
40 		cursorIdx: 1,
41 		offsetIdx: 0,
42@@ -63,7 +63,7 @@ func TestOneLetter(t *testing.T) {
43 }
44 
45 func TestFourLetters(t *testing.T) {
46-	e := newEditor(5)
47+	e := NewEditor(5, nil)
48 	e.PutRune('h')
49 	e.PutRune('e')
50 	e.PutRune('l')
51@@ -72,7 +72,7 @@ func TestFourLetters(t *testing.T) {
52 }
53 
54 func TestOneLeft(t *testing.T) {
55-	e := newEditor(5)
56+	e := NewEditor(5, nil)
57 	e.PutRune('h')
58 	e.PutRune('l')
59 	e.Left()
60@@ -83,7 +83,7 @@ func TestOneLeft(t *testing.T) {
61 }
62 
63 func TestOneRem(t *testing.T) {
64-	e := newEditor(5)
65+	e := NewEditor(5, nil)
66 	e.PutRune('h')
67 	e.PutRune('l')
68 	e.RemRune()
69@@ -94,7 +94,7 @@ func TestOneRem(t *testing.T) {
70 }
71 
72 func TestLeftAndRem(t *testing.T) {
73-	e := newEditor(5)
74+	e := NewEditor(5, nil)
75 	e.PutRune('h')
76 	e.PutRune('l')
77 	e.PutRune('e')