mirror of
https://github.com/imjasonh/csvstruct
synced 2026-07-08 19:14:56 +00:00
struct tags
This commit is contained in:
parent
ec6e566ed1
commit
e1ffca054c
2 changed files with 25 additions and 3 deletions
|
|
@ -75,3 +75,21 @@ a,b`))
|
|||
t.Errorf("unexpected result, got %v, want %v", r, exp)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecode_Tags(t *testing.T) {
|
||||
type row struct {
|
||||
Foo string `csv:"renamed_foo"`
|
||||
Bar string
|
||||
Ignored string `csv:"-"`
|
||||
}
|
||||
d := NewDecoder(strings.NewReader(`renamed_foo,Bar,Ignored
|
||||
a,b,c`))
|
||||
var r row
|
||||
if err := d.DecodeNext(&r); err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
exp := row{"a", "b", ""}
|
||||
if !reflect.DeepEqual(r, exp) {
|
||||
t.Errorf("unexpected results, got %v, want %v", r, exp)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue