File: csvutil_go17_test.go

package info (click to toggle)
golang-github-jszwec-csvutil 1.7.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 396 kB
  • sloc: makefile: 2
file content (36 lines) | stat: -rw-r--r-- 745 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//go:build !go1.10
// +build !go1.10

package csvutil

import (
	"encoding/csv"
	"testing"
)

var testUnmarshalInvalidFirstLineErr = &csv.ParseError{
	Line:   1,
	Column: 1,
	Err:    csv.ErrQuote,
}

var testUnmarshalInvalidSecondLineErr = &csv.ParseError{
	Line:   2,
	Column: 1,
	Err:    csv.ErrQuote,
}

var ptrUnexportedEmbeddedDecodeErr error

func TestUnmarshalGo17(t *testing.T) {
	t.Run("unmarshal type error message", func(t *testing.T) {
		expected := `csvutil: cannot unmarshal "field" into Go value of type int: field "X"`
		err := Unmarshal([]byte("Y,X\n1,1\n2,field"), &[]A{})
		if err == nil {
			t.Fatal("want err not to be nil")
		}
		if err.Error() != expected {
			t.Errorf("want=%s; got %s", expected, err.Error())
		}
	})
}