aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/gizak/termui/grid_test.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-06-24 23:40:18 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-06-24 23:40:18 +0800
commit1ce40d7581bac2b776d1e47ec49c03c0fcc7fdc1 (patch)
treef7b957645b11bc19ecf7fb29baaa13530557af7a /Godeps/_workspace/src/github.com/gizak/termui/grid_test.go
parent92ef33d97a437dce2d7b55f06342de388d95f575 (diff)
downloadgo-tangerine-1ce40d7581bac2b776d1e47ec49c03c0fcc7fdc1.tar
go-tangerine-1ce40d7581bac2b776d1e47ec49c03c0fcc7fdc1.tar.gz
go-tangerine-1ce40d7581bac2b776d1e47ec49c03c0fcc7fdc1.tar.bz2
go-tangerine-1ce40d7581bac2b776d1e47ec49c03c0fcc7fdc1.tar.lz
go-tangerine-1ce40d7581bac2b776d1e47ec49c03c0fcc7fdc1.tar.xz
go-tangerine-1ce40d7581bac2b776d1e47ec49c03c0fcc7fdc1.tar.zst
go-tangerine-1ce40d7581bac2b776d1e47ec49c03c0fcc7fdc1.zip
Godeps: remove mist remnants, add termui deps
Diffstat (limited to 'Godeps/_workspace/src/github.com/gizak/termui/grid_test.go')
-rw-r--r--Godeps/_workspace/src/github.com/gizak/termui/grid_test.go98
1 files changed, 98 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/gizak/termui/grid_test.go b/Godeps/_workspace/src/github.com/gizak/termui/grid_test.go
new file mode 100644
index 000000000..cdafb2052
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/gizak/termui/grid_test.go
@@ -0,0 +1,98 @@
+// Copyright 2015 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Use of this source code is governed by a MIT license that can
+// be found in the LICENSE file.
+
+package termui
+
+import (
+ "testing"
+
+ "github.com/davecgh/go-spew/spew"
+)
+
+var r *Row
+
+func TestRowWidth(t *testing.T) {
+ p0 := NewPar("p0")
+ p0.Height = 1
+ p1 := NewPar("p1")
+ p1.Height = 1
+ p2 := NewPar("p2")
+ p2.Height = 1
+ p3 := NewPar("p3")
+ p3.Height = 1
+
+ /* test against tree:
+
+ r
+ / \
+ 0:w 1
+ / \
+ 10:w 11
+ /
+ 110:w
+ /
+ 1100:w
+ */
+ /*
+ r = &row{
+ Span: 12,
+ Cols: []*row{
+ &row{Widget: p0, Span: 6},
+ &row{
+ Span: 6,
+ Cols: []*row{
+ &row{Widget: p1, Span: 6},
+ &row{
+ Span: 6,
+ Cols: []*row{
+ &row{
+ Span: 12,
+ Widget: p2,
+ Cols: []*row{
+ &row{Span: 12, Widget: p3}}}}}}}}}
+ */
+
+ r = NewRow(
+ NewCol(6, 0, p0),
+ NewCol(6, 0,
+ NewRow(
+ NewCol(6, 0, p1),
+ NewCol(6, 0, p2, p3))))
+
+ r.assignWidth(100)
+ if r.Width != 100 ||
+ (r.Cols[0].Width) != 50 ||
+ (r.Cols[1].Width) != 50 ||
+ (r.Cols[1].Cols[0].Width) != 25 ||
+ (r.Cols[1].Cols[1].Width) != 25 ||
+ (r.Cols[1].Cols[1].Cols[0].Width) != 25 ||
+ (r.Cols[1].Cols[1].Cols[0].Cols[0].Width) != 25 {
+ t.Error("assignWidth fails")
+ }
+}
+
+func TestRowHeight(t *testing.T) {
+ spew.Dump()
+
+ if (r.solveHeight()) != 2 ||
+ (r.Cols[1].Cols[1].Height) != 2 ||
+ (r.Cols[1].Cols[1].Cols[0].Height) != 2 ||
+ (r.Cols[1].Cols[0].Height) != 1 {
+ t.Error("solveHeight fails")
+ }
+}
+
+func TestAssignXY(t *testing.T) {
+ r.assignX(0)
+ r.assignY(0)
+ if (r.Cols[0].X) != 0 ||
+ (r.Cols[1].Cols[0].X) != 50 ||
+ (r.Cols[1].Cols[1].X) != 75 ||
+ (r.Cols[1].Cols[1].Cols[0].X) != 75 ||
+ (r.Cols[1].Cols[0].Y) != 0 ||
+ (r.Cols[1].Cols[1].Cols[0].Y) != 0 ||
+ (r.Cols[1].Cols[1].Cols[0].Cols[0].Y) != 1 {
+ t.Error("assignXY fails")
+ }
+}