-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtiny_lcd_test.go
57 lines (43 loc) · 1.16 KB
/
tiny_lcd_test.go
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
package lcd
import (
"strings"
"testing"
"github.com/mdw-go/testing/should"
)
func TestLCDFixture(t *testing.T) {
should.Run(&LCDFixture{T: should.New(t)}, should.Options.UnitTests())
}
type LCDFixture struct {
*should.T
lcd *LCD
}
func (this *LCDFixture) Setup() {
this.lcd = NewLCD(7, 3)
}
func (this *LCDFixture) assertScreen(expected string) {
result := this.lcd.String()
result = strings.Replace(result, "\n", "|", -1)
result = strings.Replace(result, " ", ".", -1)
this.So(result, should.Equal, expected)
}
func (this *LCDFixture) TestAllOff() {
this.assertScreen(".......|.......|.......")
}
func (this *LCDFixture) TestOneOn() {
this.lcd.RectangleOn(1, 1)
this.assertScreen("#......|.......|.......")
}
func (this *LCDFixture) TestAllOn() {
this.lcd.RectangleOn(7, 3)
this.assertScreen("#######|#######|#######")
}
func (this *LCDFixture) TestSequence() {
this.lcd.RectangleOn(3, 2)
this.assertScreen("###....|###....|.......")
this.lcd.RotateColumn(1, 1)
this.assertScreen("#.#....|###....|.#.....")
this.lcd.RotateRow(0, 4)
this.assertScreen("....#.#|###....|.#.....")
this.lcd.RotateColumn(1, 1)
this.assertScreen(".#..#.#|#.#....|.#.....")
}