mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-04 10:57:50 +08:00
26 lines
379 B
Go
26 lines
379 B
Go
package edit
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
var wcwidthTests = []struct {
|
|
in rune
|
|
wanted int
|
|
}{
|
|
{'\u0301', 0}, // Combining acute accent
|
|
{'a', 1},
|
|
{'Ω', 1},
|
|
{'好', 2},
|
|
{'か', 2},
|
|
}
|
|
|
|
func TestWcwidth(t *testing.T) {
|
|
for _, tt := range wcwidthTests {
|
|
out := WcWidth(tt.in)
|
|
if out != tt.wanted {
|
|
t.Errorf("wcwidth(%q) => %v, want %v", tt.in, out, tt.wanted)
|
|
}
|
|
}
|
|
}
|