File: progress-bar_test.go

package info (click to toggle)
kitty 0.45.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,468 kB
  • sloc: ansic: 84,285; python: 57,992; objc: 5,432; sh: 1,333; xml: 364; makefile: 144; javascript: 78
file content (25 lines) | stat: -rw-r--r-- 549 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
// License: GPLv3 Copyright: 2022, Kovid Goyal, <kovid at kovidgoyal.net>

package tui

import (
	"fmt"
	"github.com/kovidgoyal/kitty/tools/wcswidth"
	"testing"
)

var _ = fmt.Print

func TestRenderProgressBar(t *testing.T) {

	test := func(frac float64, width int) {
		b := RenderProgressBar(frac, width)
		a := wcswidth.Stringwidth(b)
		if a != width {
			t.Fatalf("Actual length %d != Expected length %d with fraction: %v\n%s", a, width, frac, b)
		}
	}
	test(0.9376609994848016, 47)
	test(0.9459041731066461, 47)
	test(0.9500257599175682, 47)
}