aboutsummaryrefslogtreecommitdiff
path: root/lib/strings/row_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-08-03 22:27:33 +0700
committerShulhan <ms@kilabit.info>2022-08-03 22:27:33 +0700
commitec98ea095fa85b5a4b64bd7ad37414c30d14310e (patch)
treea0d0af0ad27852b1644972ee2b11e870ea5acc03 /lib/strings/row_test.go
parent39d9c20c35a11c44cdd27783e407c1225027d820 (diff)
downloadpakakeh.go-ec98ea095fa85b5a4b64bd7ad37414c30d14310e.tar.xz
lib/strings: clean up test codes
Changes, * Use test.Data for test that require longer text input and output * Replace variable declaration ":=" with explicit one. * Use literal string
Diffstat (limited to 'lib/strings/row_test.go')
-rw-r--r--lib/strings/row_test.go84
1 files changed, 49 insertions, 35 deletions
diff --git a/lib/strings/row_test.go b/lib/strings/row_test.go
index b3ac097d..2d63f501 100644
--- a/lib/strings/row_test.go
+++ b/lib/strings/row_test.go
@@ -11,56 +11,70 @@ import (
)
func TestRowIsEqual(t *testing.T) {
- cases := []struct {
- a, b Row
- exp bool
- }{{
- a: Row{{"a"}, {"b", "c"}},
- b: Row{{"a"}, {"b", "c"}},
+ type testCase struct {
+ a Row
+ b Row
+ exp bool
+ }
+
+ var cases = []testCase{{
+ a: Row{{`a`}, {`b`, `c`}},
+ b: Row{{`a`}, {`b`, `c`}},
exp: true,
}, {
- a: Row{{"a"}, {"b", "c"}},
- b: Row{{"a"}, {"c", "b"}},
+ a: Row{{`a`}, {`b`, `c`}},
+ b: Row{{`a`}, {`c`, `b`}},
exp: true,
}, {
- a: Row{{"a"}, {"b", "c"}},
- b: Row{{"c", "b"}, {"a"}},
+ a: Row{{`a`}, {`b`, `c`}},
+ b: Row{{`c`, `b`}, {`a`}},
exp: true,
}, {
- a: Row{{"a"}, {"b", "c"}},
- b: Row{{"a"}, {"b", "a"}},
+ a: Row{{`a`}, {`b`, `c`}},
+ b: Row{{`a`}, {`b`, `a`}},
}}
- for _, c := range cases {
- got := c.a.IsEqual(c.b)
- test.Assert(t, "", c.exp, got)
+ var (
+ c testCase
+ got bool
+ )
+ for _, c = range cases {
+ got = c.a.IsEqual(c.b)
+ test.Assert(t, ``, c.exp, got)
}
}
func TestRowJoin(t *testing.T) {
- cases := []struct {
- row Row
- lsep, ssep string
- exp string
- }{{
- //
- lsep: ";",
- ssep: ",",
- exp: "",
+ type testCase struct {
+ lsep string
+ ssep string
+ exp string
+ row Row
+ }
+ var cases = []testCase{{
+ // Empty input.
+ }, {
+ lsep: `;`,
+ ssep: `,`,
+ exp: ``,
}, {
- row: Row{{"a"}, {}},
- lsep: ";",
- ssep: ",",
- exp: "a;",
+ row: Row{{`a`}, {}},
+ lsep: `;`,
+ ssep: `,`,
+ exp: `a;`,
}, {
- row: Row{{"a"}, {"b", "c"}},
- lsep: ";",
- ssep: ",",
- exp: "a;b,c",
+ row: Row{{`a`}, {`b`, `c`}},
+ lsep: `;`,
+ ssep: `,`,
+ exp: `a;b,c`,
}}
- for _, c := range cases {
- got := c.row.Join(c.lsep, c.ssep)
- test.Assert(t, "", c.exp, got)
+ var (
+ c testCase
+ got string
+ )
+ for _, c = range cases {
+ got = c.row.Join(c.lsep, c.ssep)
+ test.Assert(t, ``, c.exp, got)
}
}