summaryrefslogtreecommitdiffstats
path: root/layout/layout_test.go
diff options
context:
space:
mode:
authorSean E. Russell <ser@ser1.net>2020-02-20 08:19:15 -0600
committerSean E. Russell <ser@ser1.net>2020-02-20 08:19:15 -0600
commit7b09a00230e059129e010039a159ef9ce7aecc11 (patch)
tree7583287cfc2fdc277d7d361ec484e17c3016a0af /layout/layout_test.go
parent66ad0f878540dee82ae2c2b5c561754b6480a157 (diff)
Issue #56. Slight improvement in layout algorithm. Still doesn't handle > 2 columns well, but it's more correct and lays the foundation for a correct solution. It's clear, however, that a full table model parser will require a substantial rewrite and, possibly, a change in the layout syntax. That would add substantial complexity, so maybe for some future effort. I'll fix the basic column layout (rowspans at the edges), and then shelve it.
Diffstat (limited to 'layout/layout_test.go')
-rw-r--r--layout/layout_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/layout/layout_test.go b/layout/layout_test.go
index d1f016d..568bbee 100644
--- a/layout/layout_test.go
+++ b/layout/layout_test.go
@@ -101,6 +101,33 @@ func TestParsing(t *testing.T) {
assert.Equal(t, 1, l.Rows[1][0].Height)
assert.Equal(t, 1.0, l.Rows[1][0].Weight)
}},
+ {"cpu/2 mem/1 6:procs\n3:temp/1 2:disk/2\npower\nnet procs", func(l layout) {
+ assert.Equal(t, 4, len(l.Rows))
+ // First row
+ assert.Equal(t, 3, len(l.Rows[0]))
+ assert.Equal(t, 1, l.Rows[0][0].Height)
+ assert.Equal(t, 0.5, l.Rows[0][0].Weight)
+ assert.Equal(t, 1, l.Rows[0][1].Height)
+ assert.Equal(t, 0.25, l.Rows[0][1].Weight)
+ assert.Equal(t, 6, l.Rows[0][2].Height)
+ assert.Equal(t, 0.25, l.Rows[0][2].Weight)
+ // Second row
+ assert.Equal(t, 2, len(l.Rows[1]))
+ assert.Equal(t, 3, l.Rows[1][0].Height)
+ assert.Equal(t, 1/3.0, l.Rows[1][0].Weight)
+ assert.Equal(t, 2, l.Rows[1][1].Height)
+ assert.Equal(t, 2/3.0, l.Rows[1][1].Weight)
+ // Third row
+ assert.Equal(t, 1, len(l.Rows[2]))
+ assert.Equal(t, 1, l.Rows[2][0].Height)
+ assert.Equal(t, 1.0, l.Rows[2][0].Weight)
+ // Fourth row
+ assert.Equal(t, 2, len(l.Rows[3]))
+ assert.Equal(t, 1, l.Rows[3][0].Height)
+ assert.Equal(t, 0.5, l.Rows[3][0].Weight)
+ assert.Equal(t, 1, l.Rows[3][1].Height)
+ assert.Equal(t, 0.5, l.Rows[3][1].Weight)
+ }},
}
for _, tc := range tests {