aboutsummaryrefslogtreecommitdiff
path: root/main_test.go
diff options
context:
space:
mode:
authorNæþ'n Lasseter <Næþ'n Lasseter nathan@bytemark.co.uk>2016-05-01 11:45:25 +0100
committerNæþ'n Lasseter <Næþ'n Lasseter nathan@bytemark.co.uk>2016-05-01 11:45:25 +0100
commit676f71f5d0ce65b48120a6e477bd4a29233c0916 (patch)
tree637c9a030e5721a85431dc2bef5253d40880bc0a /main_test.go
Initial CommitHEADmaster
Diffstat (limited to 'main_test.go')
-rw-r--r--main_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/main_test.go b/main_test.go
new file mode 100644
index 0000000..c3e9d2e
--- /dev/null
+++ b/main_test.go
@@ -0,0 +1,36 @@
+package main
+
+import (
+ "github.com/gocarina/gocsv"
+ "testing"
+)
+
+type Type struct {
+ Headerless string `csv:""`
+ Headered string `csv:"header"`
+}
+
+func TestNoHeader(t *testing.T) {
+ types := []*Type{}
+ csv := `,header
+foo,bar
+baz,quux`
+
+ if err := gocsv.UnmarshalString(csv, &types); err != nil {
+ t.Fatal(err)
+ }
+
+ for i, tc := range []struct {
+ actual string
+ expected string
+ }{
+ {types[0].Headerless, "foo"},
+ {types[0].Headered, "bar"},
+ {types[1].Headerless, "baz"},
+ {types[1].Headered, "quux"},
+ } {
+ if tc.actual != tc.expected {
+ t.Errorf("Test case %d: Got \"%s\", expected \"%s\"", i, tc.actual, tc.expected)
+ }
+ }
+}