diff options
author | spf13 <steve.francia@gmail.com> | 2014-04-23 10:52:01 +0400 |
---|---|---|
committer | spf13 <steve.francia@gmail.com> | 2014-04-23 10:53:12 +0400 |
commit | 4a8de8ea46f45776518c7086222be0c94c893764 (patch) | |
tree | 991fa4e3166acda6d7d50f3f104c18321490c0f8 /hugolib/template_test.go | |
parent | 41adafbc3e8c53475ba9a8bc8031dd4e0bf59664 (diff) |
Add Disqus support out of the box. Move template/bundle into hugolib.
Diffstat (limited to 'hugolib/template_test.go')
-rw-r--r-- | hugolib/template_test.go | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/hugolib/template_test.go b/hugolib/template_test.go new file mode 100644 index 000000000..ffc417b4c --- /dev/null +++ b/hugolib/template_test.go @@ -0,0 +1,55 @@ +package hugolib + +import ( + "reflect" + "testing" +) + +func TestGt(t *testing.T) { + for i, this := range []struct { + left interface{} + right interface{} + leftShouldWin bool + }{ + {5, 8, false}, + {8, 5, true}, + {5, 5, false}, + {-2, 1, false}, + {2, -5, true}, + {"8", "5", true}, + {"5", "0001", true}, + {[]int{100, 99}, []int{1, 2, 3, 4}, false}, + } { + leftIsBigger := Gt(this.left, this.right) + if leftIsBigger != this.leftShouldWin { + var which string + if leftIsBigger { + which = "expected right to be bigger, but left was" + } else { + which = "expected left to be bigger, but right was" + } + t.Errorf("[%d] %v compared to %v: %s", i, this.left, this.right, which) + } + } +} + +func TestFirst(t *testing.T) { + for i, this := range []struct { + count int + sequence interface{} + expect interface{} + }{ + {2, []string{"a", "b", "c"}, []string{"a", "b"}}, + {3, []string{"a", "b"}, []string{"a", "b"}}, + {2, []int{100, 200, 300}, []int{100, 200}}, + } { + results, err := First(this.count, this.sequence) + if err != nil { + t.Errorf("[%d] failed: %s", i, err) + continue + } + if !reflect.DeepEqual(results, this.expect) { + t.Errorf("[%d] First %d items, got %v but expected %v", i, this.count, results, this.expect) + } + } +} |