aboutsummaryrefslogtreecommitdiff
path: root/lib/strings/row_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2018-09-17 00:26:46 +0700
committerShulhan <ms@kilabit.info>2018-09-17 22:51:23 +0700
commit66caeb368336e9f149d6f40772e7f0fdd070cf78 (patch)
treed0295d2fb895ce9e046400fae90cd7d69081c16a /lib/strings/row_test.go
parentf911fdc362d2a98a9f4deb93c18231ae77df12a1 (diff)
downloadpakakeh.go-66caeb368336e9f149d6f40772e7f0fdd070cf78.tar.xz
Merge package "github.com/shuLhan/tekstus", part 3/3
Diffstat (limited to 'lib/strings/row_test.go')
-rw-r--r--lib/strings/row_test.go66
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/strings/row_test.go b/lib/strings/row_test.go
new file mode 100644
index 00000000..dc7c0519
--- /dev/null
+++ b/lib/strings/row_test.go
@@ -0,0 +1,66 @@
+// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package strings
+
+import (
+ "testing"
+
+ "github.com/shuLhan/share/lib/test"
+)
+
+func TestRowIsEqual(t *testing.T) {
+ cases := []struct {
+ a, b Row
+ exp bool
+ }{{
+ a: Row{{"a"}, {"b", "c"}},
+ b: Row{{"a"}, {"b", "c"}},
+ exp: true,
+ }, {
+ a: Row{{"a"}, {"b", "c"}},
+ b: Row{{"a"}, {"c", "b"}},
+ exp: true,
+ }, {
+ a: Row{{"a"}, {"b", "c"}},
+ b: Row{{"c", "b"}, {"a"}},
+ exp: true,
+ }, {
+ 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, true)
+ }
+}
+
+func TestRowJoin(t *testing.T) {
+ cases := []struct {
+ row Row
+ lsep, ssep string
+ exp string
+ }{{
+ //
+ lsep: ";",
+ ssep: ",",
+ exp: "",
+ }, {
+ row: Row{{"a"}, {}},
+ lsep: ";",
+ ssep: ",",
+ exp: "a;",
+ }, {
+ 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, true)
+ }
+}