diff options
author | bep <bjorn.erik.pedersen@gmail.com> | 2015-04-15 20:31:05 +0200 |
---|---|---|
committer | bep <bjorn.erik.pedersen@gmail.com> | 2015-04-15 20:31:06 +0200 |
commit | be24457acfd3eb0b798edda36c89632564e981c7 (patch) | |
tree | c5238e125c542496ea6a23b7ef843d93a6c0819d /helpers/pygments_test.go | |
parent | be540f5b8fb340f1edfb1ed10c11334bbb85927b (diff) |
Add more options to highlight
Fixes #1021
Diffstat (limited to 'helpers/pygments_test.go')
-rw-r--r-- | helpers/pygments_test.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/helpers/pygments_test.go b/helpers/pygments_test.go new file mode 100644 index 000000000..be0c1a7dc --- /dev/null +++ b/helpers/pygments_test.go @@ -0,0 +1,42 @@ +package helpers + +import ( + "github.com/spf13/viper" + "testing" +) + +func TestParsePygmentsArgs(t *testing.T) { + for i, this := range []struct { + in string + pygmentsStyle string + pygmentsUseClasses bool + expect1 interface{} + }{ + {"", "foo", true, "style=foo,noclasses=false,encoding=utf8"}, + {"style=boo,noclasses=true", "foo", true, "encoding=utf8,noclasses=true,style=boo"}, + {"Style=boo, noClasses=true", "foo", true, "encoding=utf8,noclasses=true,style=boo"}, + {"noclasses=true", "foo", true, "encoding=utf8,noclasses=true,style=foo"}, + {"style=boo", "foo", true, "encoding=utf8,noclasses=false,style=boo"}, + {"boo=invalid", "foo", false, false}, + {"style", "foo", false, false}, + } { + viper.Set("PygmentsStyle", this.pygmentsStyle) + viper.Set("PygmentsUseClasses", this.pygmentsUseClasses) + + result1, err := parsePygmentsOpts(this.in) + if b, ok := this.expect1.(bool); ok && !b { + if err == nil { + t.Errorf("[%d] parsePygmentArgs didn't return an expected error", i) + } + } else { + if err != nil { + t.Errorf("[%d] parsePygmentArgs failed: %s", i, err) + continue + } + if result1 != this.expect1 { + t.Errorf("[%d] parsePygmentArgs got %v but expected %v", i, result1, this.expect1) + } + + } + } +} |