Get basic full string width tests running

This commit is contained in:
Kovid Goyal
2025-04-11 10:45:39 +05:30
parent cf6bb29ef7
commit 3a4d32b85b
4 changed files with 137 additions and 11 deletions

View File

@@ -1,12 +1,12 @@
package wcswidth
import (
"encoding/json"
"fmt"
"strings"
"testing"
_ "embed"
"github.com/google/go-cmp/cmp"
"kitty"
@@ -14,11 +14,6 @@ import (
var _ = fmt.Print
type GraphemeBreakTest struct {
Data []string `json:"data"`
Comment string `json:"comment"`
}
func TestSplitIntoGraphemes(t *testing.T) {
var m = map[string][]string{
" \u0308 ": {" \u0308", " "},
@@ -29,9 +24,9 @@ func TestSplitIntoGraphemes(t *testing.T) {
t.Fatalf("Failed to split %#v into graphemes: %s", text, diff)
}
}
tests := []GraphemeBreakTest{}
if err := json.Unmarshal(kitty.GraphemeBreakTestData, &tests); err != nil {
t.Fatalf("Failed to parse GraphemeBreakTest JSON with error: %s", err)
tests, err := kitty.LoadGraphemeBreakTests()
if err != nil {
t.Fatal(err)
}
for i, x := range tests {
text := strings.Join(x.Data, "")