Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,3 +756,18 @@ func BenchmarkAppendEscapedTextNoEscape(b *testing.B) {
appendEscapedText(nil, longString)
}
}

//TestRoundtripDecodeEncode tests that encode and decode work roundtrip,
//ie Parse(Format(t)) should equal t. lib/pq#606
func TestRoundtripDecodeEncode(t *testing.T) {
inTime := time.Now().UTC()
inDate := FormatTimestamp(inTime)
outTime, err := ParseTimestamp(time.UTC, string(inDate))
if err != nil {
t.Errorf("ParseTimestamp fails on FormatTimestamp with input %v with error: %v\n", inTime, err)
}
if !outTime.Equal(inTime) {
t.Errorf("Parse(Format(t)) did not equal t, expected %v and got %v\n", inTime, outTime)
}

}