go-chart/stringutil_test.go

23 lines
811 B
Go
Raw Permalink Normal View History

2019-02-13 19:09:26 -05:00
package chart
import (
"testing"
"github.com/blend/go-sdk/assert"
)
func TestSplitCSV(t *testing.T) {
assert := assert.New(t)
assert.Empty(SplitCSV(""))
assert.Equal([]string{"foo"}, SplitCSV("foo"))
assert.Equal([]string{"foo", "bar"}, SplitCSV("foo,bar"))
assert.Equal([]string{"foo", "bar"}, SplitCSV("foo, bar"))
assert.Equal([]string{"foo", "bar"}, SplitCSV(" foo , bar "))
assert.Equal([]string{"foo", "bar", "baz"}, SplitCSV("foo,bar,baz"))
assert.Equal([]string{"foo", "bar", "baz,buzz"}, SplitCSV("foo,bar,\"baz,buzz\""))
assert.Equal([]string{"foo", "bar", "baz,'buzz'"}, SplitCSV("foo,bar,\"baz,'buzz'\""))
assert.Equal([]string{"foo", "bar", "baz,'buzz"}, SplitCSV("foo,bar,\"baz,'buzz\""))
assert.Equal([]string{"foo", "bar", "baz,\"buzz\""}, SplitCSV("foo,bar,'baz,\"buzz\"'"))
}