Support icon color (#1674)

* Support icon color

* Rename variables

* Test for readArrays

* Add doc and examples for icon color
This commit is contained in:
Daniel Zhang authored and GitHub committed 2024-04-20 21:41:37 +02:00
1 parent ce12116418
commit 6cabb0e8e4
8 files changed
+490 -43

No files matched your search

+16 -12
View File
@@ -217,23 +217,27 @@ func TestSplitWord(t *testing.T) {
}
}
func TestReadPairs(t *testing.T) {
func TestReadArrays(t *testing.T) {
tests := []struct {
s string
exp [][]string
s string
min_cols int
max_cols int
exp [][]string
}{
{"foo bar", [][]string{{"foo", "bar"}}},
{"foo bar ", [][]string{{"foo", "bar"}}},
{" foo bar", [][]string{{"foo", "bar"}}},
{" foo bar ", [][]string{{"foo", "bar"}}},
{"foo bar#baz", [][]string{{"foo", "bar"}}},
{"foo bar #baz", [][]string{{"foo", "bar"}}},
{`'foo#baz' bar`, [][]string{{"foo#baz", "bar"}}},
{`"foo#baz" bar`, [][]string{{"foo#baz", "bar"}}},
{"foo bar", 2, 2, [][]string{{"foo", "bar"}}},
{"foo bar ", 2, 2, [][]string{{"foo", "bar"}}},
{" foo bar", 2, 2, [][]string{{"foo", "bar"}}},
{" foo bar ", 2, 2, [][]string{{"foo", "bar"}}},
{"foo bar#baz", 2, 2, [][]string{{"foo", "bar"}}},
{"foo bar #baz", 2, 2, [][]string{{"foo", "bar"}}},
{`'foo#baz' bar`, 2, 2, [][]string{{"foo#baz", "bar"}}},
{`"foo#baz" bar`, 2, 2, [][]string{{"foo#baz", "bar"}}},
{"foo bar baz", 3, 3, [][]string{{"foo", "bar", "baz"}}},
{`"foo bar baz"`, 1, 1, [][]string{{"foo bar baz"}}},
}
for _, test := range tests {
if got, _ := readPairs(strings.NewReader(test.s)); !reflect.DeepEqual(got, test.exp) {
if got, _ := readArrays(strings.NewReader(test.s), test.min_cols, test.max_cols); !reflect.DeepEqual(got, test.exp) {
t.Errorf("at input '%v' expected '%v' but got '%v'", test.s, test.exp, got)
}
}