forked from gnolang/gno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types_test.go
46 lines (41 loc) · 1.1 KB
/
types_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
package logos
import (
"testing"
require "github.com/jaekwon/testify/require"
)
func TestNewPage1(t *testing.T) {
page := NewPage("this is a new string", 40, false, nil)
require.NotNil(t, page)
size := page.Size
require.Equal(t, size, Size{Width: 20, Height: 1})
}
func TestNewPage2(t *testing.T) {
page := NewPage("this is a new string", 10, false, nil)
require.NotNil(t, page)
size := page.Size
/*
0123456789
this is a
new string
*/
require.Equal(t, size, Size{Width: 10, Height: 2})
require.Equal(t, page.Elems[0].GetCoord(), Coord{0, 0})
require.Equal(t, page.Elems[1].GetCoord(), Coord{5, 0})
require.Equal(t, page.Elems[2].GetCoord(), Coord{8, 0})
require.Equal(t, page.Elems[3].GetCoord(), Coord{0, 1})
require.Equal(t, page.Elems[4].GetCoord(), Coord{4, 1})
require.Equal(t, len(page.Elems), 5)
}
func TestNewPageSprint(t *testing.T) {
page := NewPage("this is a new string", 10, false, nil)
require.NotNil(t, page)
/*
0123456789
this is a
new string
*/
bpv := NewBufferedElemView(page, Size{})
bpv.Render()
out := bpv.Sprint()
require.Equal(t, out, "this is a \nnew string")
}