File: runecount_test.go

package info (click to toggle)
golang-github-cheggaaa-pb.v3 3.1.5-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 344 kB
  • sloc: makefile: 2
file content (20 lines) | stat: -rw-r--r-- 508 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package pb

import "testing"

func Test_RuneCount(t *testing.T) {
	s := string([]byte{
		27, 91, 51, 49, 109, // {Red}
		72, 101, 108, 108, 111, // Hello
		44, 32, // ,
		112, 108, 97, 121, 103, 114, 111, 117, 110, 100, // Playground
		27, 91, 48, 109, // {Reset}
	})
	if e, l := 17, escapeAwareRuneCountInString(s); l != e {
		t.Errorf("Invalid length %d, expected %d", l, e)
	}
	s = "進捗 "
	if e, l := 5, escapeAwareRuneCountInString(s); l != e {
		t.Errorf("Invalid length %d, expected %d", l, e)
	}
}