File: fill_test.go

package info (click to toggle)
golang-github-gcla-gowid 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,456 kB
  • sloc: makefile: 4
file content (73 lines) | stat: -rw-r--r-- 2,021 bytes parent folder | download
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
// Copyright 2019-2022 Graham Clark. All rights reserved.  Use of this source
// code is governed by the MIT license that can be found in the LICENSE
// file.

package fill

import (
	"strings"
	"testing"

	"github.com/gcla/gowid"
	"github.com/gcla/gowid/gwtest"
	log "github.com/sirupsen/logrus"
	"github.com/stretchr/testify/assert"
)

func TestSolidFill1(t *testing.T) {
	w := New('G')

	c1 := w.Render(gowid.RenderFlowWith{C: 5}, gowid.Focused, gwtest.D)
	assert.Equal(t, c1.String(), "GGGGG")

	c2 := w.Render(gowid.RenderBox{C: 3, R: 3}, gowid.Focused, gwtest.D)
	assert.Equal(t, c2.String(), "GGG\nGGG\nGGG")

	assert.Panics(t, func() {
		w.Render(gowid.RenderFixed{}, gowid.Focused, gwtest.D)
	})

	gwtest.RenderBoxManyTimes(t, w, 0, 10, 0, 10)
}

func TestCanvas21(t *testing.T) {
	widget1 := New('x')
	canvas1 := widget1.Render(gowid.RenderFlowWith{C: 6}, gowid.NotSelected, gwtest.D)
	log.Infof("Widget is %v", widget1)
	log.Infof("Canvas is %s", canvas1.String())
	res := strings.Join([]string{"xxxxxx"}, "\n")
	if res != canvas1.String() {
		t.Errorf("Failed")
	}
}

func TestCanvas22(t *testing.T) {
	widget1 := New('x')
	canvas1 := widget1.Render(gowid.RenderBox{C: 6, R: 3}, gowid.NotSelected, gwtest.D)
	log.Infof("Widget is %v", widget1)
	log.Infof("Canvas is %s", canvas1.String())
	res := strings.Join([]string{"xxxxxx", "xxxxxx", "xxxxxx"}, "\n")
	if res != canvas1.String() {
		t.Errorf("Failed")
	}
}

func TestCanvas29(t *testing.T) {
	widget1 := New('x')
	canvas1 := widget1.Render(gowid.RenderFlowWith{C: 6}, gowid.NotSelected, gwtest.D)
	canvas2 := gowid.NewCanvasOfSize(6, 1)
	canvas2.Lines[0][1] = canvas2.Lines[0][1].WithRune('#')
	canvas1.MergeUnder(canvas2, 0, 0, false)
	log.Infof("Widget is %v", widget1)
	log.Infof("Canvas is %s", canvas1.String())
	res := strings.Join([]string{"x#xxxx"}, "\n")
	if res != canvas1.String() {
		t.Errorf("Failed")
	}
}

//======================================================================
// Local Variables:
// mode: Go
// fill-column: 110
// End: