diff --git a/pgtype/bool_test.go b/pgtype/bool_test.go index 50725d6a..53df1747 100644 --- a/pgtype/bool_test.go +++ b/pgtype/bool_test.go @@ -22,11 +22,11 @@ func TestBoolConvertFrom(t *testing.T) { result pgtype.Bool }{ {source: true, result: pgtype.Bool{Bool: true, Status: pgtype.Present}}, - {source: false, result: pgtype.Bool{Bool: true, Status: pgtype.Present}}, + {source: false, result: pgtype.Bool{Bool: false, Status: pgtype.Present}}, {source: "true", result: pgtype.Bool{Bool: true, Status: pgtype.Present}}, - {source: "false", result: pgtype.Bool{Bool: true, Status: pgtype.Present}}, + {source: "false", result: pgtype.Bool{Bool: false, Status: pgtype.Present}}, {source: "t", result: pgtype.Bool{Bool: true, Status: pgtype.Present}}, - {source: "f", result: pgtype.Bool{Bool: true, Status: pgtype.Present}}, + {source: "f", result: pgtype.Bool{Bool: false, Status: pgtype.Present}}, } for i, tt := range successfulTests { @@ -35,5 +35,9 @@ func TestBoolConvertFrom(t *testing.T) { if err != nil { t.Errorf("%d: %v", i, err) } + + if r != tt.result { + t.Errorf("%d: expected %v to convert to %v, but it was %v", i, tt.source, tt.result, r) + } } } diff --git a/pgtype/date_test.go b/pgtype/date_test.go index 21bc6fa3..c3e971d0 100644 --- a/pgtype/date_test.go +++ b/pgtype/date_test.go @@ -26,15 +26,15 @@ func TestDateConvertFrom(t *testing.T) { successfulTests := []struct { source interface{} - result *pgtype.Date + result pgtype.Date }{ - {source: time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC), result: &pgtype.Date{Time: time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}}, - {source: time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC), result: &pgtype.Date{Time: time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}}, - {source: time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC), result: &pgtype.Date{Time: time.Date(1999, 12, 31, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}}, - {source: time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC), result: &pgtype.Date{Time: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}}, - {source: time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC), result: &pgtype.Date{Time: time.Date(2000, 1, 2, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}}, - {source: time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC), result: &pgtype.Date{Time: time.Date(2200, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}}, - {source: _time(time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC)), result: &pgtype.Date{Time: time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}}, + {source: time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC), result: pgtype.Date{Time: time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}}, + {source: time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC), result: pgtype.Date{Time: time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}}, + {source: time.Date(1999, 12, 31, 0, 0, 0, 0, time.UTC), result: pgtype.Date{Time: time.Date(1999, 12, 31, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}}, + {source: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), result: pgtype.Date{Time: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}}, + {source: time.Date(2000, 1, 2, 0, 0, 0, 0, time.UTC), result: pgtype.Date{Time: time.Date(2000, 1, 2, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}}, + {source: time.Date(2200, 1, 1, 0, 0, 0, 0, time.UTC), result: pgtype.Date{Time: time.Date(2200, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}}, + {source: _time(time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC)), result: pgtype.Date{Time: time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}}, } for i, tt := range successfulTests { @@ -43,5 +43,9 @@ func TestDateConvertFrom(t *testing.T) { if err != nil { t.Errorf("%d: %v", i, err) } + + if d != tt.result { + t.Errorf("%d: expected %v to convert to %v, but it was %v", i, tt.source, tt.result, d) + } } } diff --git a/pgtype/int2_test.go b/pgtype/int2_test.go index 0186ccd3..a8493a16 100644 --- a/pgtype/int2_test.go +++ b/pgtype/int2_test.go @@ -47,5 +47,9 @@ func TestInt2ConvertFrom(t *testing.T) { if err != nil { t.Errorf("%d: %v", i, err) } + + if r != tt.result { + t.Errorf("%d: expected %v to convert to %v, but it was %v", i, tt.source, tt.result, r) + } } } diff --git a/pgtype/int4_test.go b/pgtype/int4_test.go index 9e994909..04411849 100644 --- a/pgtype/int4_test.go +++ b/pgtype/int4_test.go @@ -47,5 +47,9 @@ func TestInt4ConvertFrom(t *testing.T) { if err != nil { t.Errorf("%d: %v", i, err) } + + if r != tt.result { + t.Errorf("%d: expected %v to convert to %v, but it was %v", i, tt.source, tt.result, r) + } } } diff --git a/pgtype/int8_test.go b/pgtype/int8_test.go index 1480e36f..ba246224 100644 --- a/pgtype/int8_test.go +++ b/pgtype/int8_test.go @@ -47,5 +47,9 @@ func TestInt8ConvertFrom(t *testing.T) { if err != nil { t.Errorf("%d: %v", i, err) } + + if r != tt.result { + t.Errorf("%d: expected %v to convert to %v, but it was %v", i, tt.source, tt.result, r) + } } } diff --git a/pgtype/timestamptz_test.go b/pgtype/timestamptz_test.go index e650ffbb..795195f8 100644 --- a/pgtype/timestamptz_test.go +++ b/pgtype/timestamptz_test.go @@ -47,14 +47,14 @@ func TestTimestamptzConvertFrom(t *testing.T) { } for i, tt := range successfulTests { - var d pgtype.Timestamptz - err := d.ConvertFrom(tt.source) + var r pgtype.Timestamptz + err := r.ConvertFrom(tt.source) if err != nil { t.Errorf("%d: %v", i, err) } - if d != tt.result { - t.Errorf("%d: expected %v to convert to %v, but it was %v", i, tt.source, tt.result, d) + if r != tt.result { + t.Errorf("%d: expected %v to convert to %v, but it was %v", i, tt.source, tt.result, r) } } }