-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcell_test.go
More file actions
77 lines (71 loc) · 2.42 KB
/
cell_test.go
File metadata and controls
77 lines (71 loc) · 2.42 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright (c) 2022-2023 The Go-Curses Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use file except in compliance with the License.
// You may obtain a copy of the license at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package cdk
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
"github.com/go-curses/cdk/lib/paint"
)
func TestCellBasics(t *testing.T) {
Convey("Cell basics", t, func() {
c := newCell()
So(c, ShouldNotBeNil)
So(c.init(), ShouldEqual, false)
})
}
func TestCellBufferBasics(t *testing.T) {
Convey("CellBuffer basics", t, func() {
cb := NewCellBuffer()
So(cb, ShouldNotBeNil)
So(cb.init(), ShouldEqual, false)
cb.Resize(1, 1)
cb.SetCell(0, 0, '0', []rune{'0'}, paint.StyleDefault)
So(cb.Dirty(0, 0), ShouldEqual, true)
cb.SetDirty(0, 0, false)
So(cb.Dirty(0, 0), ShouldEqual, false)
cb.Invalidate()
So(cb.Dirty(0, 0), ShouldEqual, true)
cb.SetDirty(0, 0, false)
So(cb.Dirty(0, 0), ShouldEqual, false)
cb.SetDirty(0, 0, true)
So(cb.Dirty(0, 0), ShouldEqual, true)
cb.SetDirty(0, 0, false)
cb.Resize(1, 1)
So(cb.Dirty(0, 0), ShouldEqual, false)
cb.SetCell(0, 0, '0', []rune{'0'}, paint.StyleDefault)
cb.SetDirty(0, 0, false)
prev_main := cb.cells[0].currMain
cb.cells[0].currMain = '1'
So(cb.Dirty(0, 0), ShouldEqual, true)
cb.cells[0].currMain = prev_main
So(cb.Dirty(0, 0), ShouldEqual, false)
prev_style := cb.cells[0].currStyle
cb.cells[0].currStyle = paint.StyleDefault.Reverse(true)
So(cb.Dirty(0, 0), ShouldEqual, true)
cb.cells[0].currStyle = prev_style
So(cb.Dirty(0, 0), ShouldEqual, false)
prev_comb := cb.cells[0].currComb
cb.cells[0].currComb = []rune{'0', '1'}
So(cb.Dirty(0, 0), ShouldEqual, true)
cb.cells[0].currComb = prev_comb
So(cb.Dirty(0, 0), ShouldEqual, false)
prev_comb = cb.cells[0].currComb
cb.cells[0].currComb = []rune{'1'}
So(cb.Dirty(0, 0), ShouldEqual, true)
cb.cells[0].currComb = prev_comb
So(cb.Dirty(0, 0), ShouldEqual, false)
cb.SetCell(0, 0, '0', nil, paint.StyleDefault)
So(len(cb.cells[0].currComb), ShouldEqual, 0)
})
}