File: divider_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 (52 lines) | stat: -rw-r--r-- 1,427 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
// 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 divider

import (
	"strings"
	"testing"

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

func TestDivider1(t *testing.T) {
	w := New(Options{Chr: '-', Above: 0, Below: 0})

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

	w2 := New(Options{Chr: 'x', Above: 1, Below: 2})

	c2 := w2.Render(gowid.RenderFlowWith{C: 5}, gowid.Focused, gwtest.D)
	assert.Equal(t, c2.String(), "     \nxxxxx\n     \n     ")

	assert.Panics(t, func() {
		w.Render(gowid.RenderBox{C: 5, R: 3}, gowid.Focused, gwtest.D)
	})

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

}

func TestCanvas20(t *testing.T) {
	widget1 := New(Options{Chr: '-', Above: 1, Below: 2})
	canvas1 := widget1.Render(gowid.RenderFlowWith{C: 6}, gowid.NotSelected, gwtest.D)
	log.Infof("Widget20 is %v", widget1)
	log.Infof("Canvas20 is %s", canvas1.String())
	res := strings.Join([]string{"      ", "------", "      ", "      "}, "\n")
	if res != canvas1.String() {
		t.Errorf("Failed")
	}
}

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