aboutsummaryrefslogtreecommitdiff
path: root/lib/tabula/maprows_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2018-09-17 01:21:27 +0700
committerShulhan <ms@kilabit.info>2018-09-18 01:50:21 +0700
commit44b26edf7f390db383fe025454be0c4e30cfbd9b (patch)
tree84d02953bc9095312182534936c1b60667957f07 /lib/tabula/maprows_test.go
parent4a820ec157501c957d2e30f1670656cceec5c044 (diff)
downloadpakakeh.go-44b26edf7f390db383fe025454be0c4e30cfbd9b.tar.xz
Merge package "github.com/shuLhan/tabula"
Diffstat (limited to 'lib/tabula/maprows_test.go')
-rw-r--r--lib/tabula/maprows_test.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/tabula/maprows_test.go b/lib/tabula/maprows_test.go
new file mode 100644
index 00000000..19cd5ac8
--- /dev/null
+++ b/lib/tabula/maprows_test.go
@@ -0,0 +1,54 @@
+// Copyright 2017, 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 tabula
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/shuLhan/share/lib/test"
+)
+
+func TestAddRow(t *testing.T) {
+ mapRows := MapRows{}
+ rows, e := initRows()
+
+ if e != nil {
+ t.Fatal(e)
+ }
+
+ for _, row := range rows {
+ key := fmt.Sprint((*row)[testClassIdx].Interface())
+ mapRows.AddRow(key, row)
+ }
+
+ got := fmt.Sprint(mapRows)
+
+ test.Assert(t, "", groupByExpect, got, true)
+}
+
+func TestGetMinority(t *testing.T) {
+ mapRows := MapRows{}
+ rows, e := initRows()
+
+ if e != nil {
+ t.Fatal(e)
+ }
+
+ for _, row := range rows {
+ key := fmt.Sprint((*row)[testClassIdx].Interface())
+ mapRows.AddRow(key, row)
+ }
+
+ // remove the first row in the first key, so we can make it minority.
+ mapRows[0].Value.PopFront()
+
+ _, minRows := mapRows.GetMinority()
+
+ exp := rowsExpect[3]
+ got := fmt.Sprint(minRows)
+
+ test.Assert(t, "", exp, got, true)
+}