Nicer way to include grapheme test data in Go tests

This commit is contained in:
Kovid Goyal
2025-03-27 03:20:27 +05:30
parent e76daa3736
commit 9e1601a9b5
5 changed files with 18 additions and 8 deletions

View File

@@ -8,13 +8,12 @@ import (
_ "embed"
"github.com/google/go-cmp/cmp"
"kitty"
)
var _ = fmt.Print
//go:embed GraphemeBreakTest.json
var test_data []byte
type GraphemeBreakTest struct {
Data []string `json:"data"`
Comment string `json:"comment"`
@@ -31,7 +30,7 @@ func TestSplitIntoGraphemes(t *testing.T) {
}
}
tests := []GraphemeBreakTest{}
if err := json.Unmarshal(test_data, &tests); err != nil {
if err := json.Unmarshal(kitty.GraphemeBreakTestData, &tests); err != nil {
t.Fatalf("Failed to parse GraphemeBreakTest JSON with error: %s", err)
}
for i, x := range tests {