Sha256: c75c7f46b11735a193376ad3965074b224e484fdecff9a8d1e28d3bf0d224348

Contents?: true

Size: 981 Bytes

Versions: 87

Compression:

Stored size: 981 Bytes

Contents

package util

import "testing"

func TestToCharsAscii(t *testing.T) {
	chars := ToChars([]byte("foobar"))
	if !chars.inBytes || chars.ToString() != "foobar" || !chars.inBytes {
		t.Error()
	}
}

func TestCharsLength(t *testing.T) {
	chars := ToChars([]byte("\tabc한글  "))
	if chars.inBytes || chars.Length() != 8 || chars.TrimLength() != 5 {
		t.Error()
	}
}

func TestCharsToString(t *testing.T) {
	text := "\tabc한글  "
	chars := ToChars([]byte(text))
	if chars.ToString() != text {
		t.Error()
	}
}

func TestTrimLength(t *testing.T) {
	check := func(str string, exp uint16) {
		chars := ToChars([]byte(str))
		trimmed := chars.TrimLength()
		if trimmed != exp {
			t.Errorf("Invalid TrimLength result for '%s': %d (expected %d)",
				str, trimmed, exp)
		}
	}
	check("hello", 5)
	check("hello ", 5)
	check("hello  ", 5)
	check(" hello", 5)
	check("  hello", 5)
	check(" hello ", 5)
	check("  hello  ", 5)
	check("h   o", 5)
	check("  h   o  ", 5)
	check("         ", 0)
}

Version data entries

87 entries across 87 versions & 1 rubygems

Version Path
doing-2.1.88 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.87 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.86 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.85 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.84 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.83 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.82 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.81 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.80 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.79 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.78 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.77 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.76 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.75 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.74 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.73 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.72 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.69 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.68 lib/helpers/fzf/src/util/chars_test.go
doing-2.1.66 lib/helpers/fzf/src/util/chars_test.go