| 731 | } |
| 732 | |
| 733 | func TestInt64ArrayScanError(t *testing.T) { |
| 734 | for _, tt := range []struct { |
| 735 | input, err string |
| 736 | }{ |
| 737 | {``, "unable to parse array"}, |
| 738 | {`{`, "unable to parse array"}, |
| 739 | {`{{5},{6}}`, "cannot convert ARRAY[2][1] to Int64Array"}, |
| 740 | {`{NULL}`, "parsing array element index 0:"}, |
| 741 | {`{a}`, "parsing array element index 0:"}, |
| 742 | {`{5,a}`, "parsing array element index 1:"}, |
| 743 | {`{5,6,a}`, "parsing array element index 2:"}, |
| 744 | } { |
| 745 | arr := Int64Array{5, 5, 5} |
| 746 | err := arr.Scan(tt.input) |
| 747 | |
| 748 | if err == nil { |
| 749 | t.Fatalf("Expected error for %q, got none", tt.input) |
| 750 | } |
| 751 | if !strings.Contains(err.Error(), tt.err) { |
| 752 | t.Errorf("Expected error to contain %q for %q, got %q", tt.err, tt.input, err) |
| 753 | } |
| 754 | if !reflect.DeepEqual(arr, Int64Array{5, 5, 5}) { |
| 755 | t.Errorf("Expected destination not to change for %q, got %+v", tt.input, arr) |
| 756 | } |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | func TestInt64ArrayValue(t *testing.T) { |
| 761 | result, err := Int64Array(nil).Value() |