-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboard_test.go
64 lines (55 loc) · 1.08 KB
/
board_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
58
59
60
61
62
63
64
package board
import (
"fmt"
"github.com/fatih/color"
)
func ExampleBoard_Import() {
board := New(NewConfig())
coords := []string{"A1", "A2", "A3"}
err := board.Import(coords)
if err != nil {
fmt.Println(err)
}
}
func ExampleBoard_Export() {
board := New(NewConfig())
coords := []string{"A1", "A2", "A3"}
_ = board.Import(coords)
exported := board.Export(Left)
fmt.Println(exported)
// Output: [A3 A2 A1]
}
func ExampleBoard_Set_enemy() {
board := New(NewConfig())
err := board.Set(Right, "C3", Hit)
if err != nil {
fmt.Println(err)
}
}
func ExampleBoard_Set_player() {
board := New(NewConfig())
err := board.Set(Left, "A1", Ship)
if err != nil {
fmt.Println(err)
}
}
func ExampleBoard_HitOrMiss() {
board := New(NewConfig())
_ = board.Set(Left, "A1", Ship)
_, err := board.HitOrMiss(Left, "A1")
if err != nil {
fmt.Println(err)
}
}
func ExampleNew_simple() {
cfg := NewConfig()
New(cfg)
}
func ExampleNew_advanced() {
cfg := NewConfig()
cfg.HitChar = '#'
cfg.HitColor = color.FgRed
cfg.BorderColor = color.BgRed
cfg.RulerTextColor = color.BgYellow
New(cfg)
}