1
0
Fork 0
mirror of https://github.com/imjasonh/csvstruct synced 2026-07-08 19:14:56 +00:00

continuing to struggle with reflect...

This commit is contained in:
Jason Hall 2014-05-15 08:31:35 -04:00
parent 86f0dda5fe
commit 49f48c08ef
2 changed files with 30 additions and 16 deletions

View file

@ -22,16 +22,21 @@ d,e,f`,
out: []row{{"a", "b", "c"}, {"d", "e", "f"}},
}, {
// Rows that only have partial data are only partially filled.
data: `Foo,Bar,Baz
a,,
,b,`,
out: []row{{"a", "", ""}, {"", "b", ""}},
}, {
// Rows that don't define all the columns are partially filled.
data: `Foo,Bar
a,
,b`,
out: []row{{"a", "", ""}, {"", "b", ""}},
}, {
// Disjoint data results in unset struct.
data: `
Qux
ignored`,
out: []row{{"", "", ""}},
/*}, {
// Entirely disjoint columns produce empty structs.
data: `Qux
d`,
out: []row{{"", "", ""}}, */
}} {
d := NewDecoder(strings.NewReader(c.data))
rows := []row{}
@ -47,7 +52,7 @@ ignored`,
}
rows = append(rows, row)
}
if reflect.DeepEqual(rows, c.out) {
if !reflect.DeepEqual(rows, c.out) {
t.Errorf("unexpected result, got %v, want %v", rows, c.out)
}
}