Skip to content

Commit

Permalink
private/protocol: Add unit tests for exponent Unix epoch seconds pars…
Browse files Browse the repository at this point in the history
…ing (#3303)

Adds a unit test to verify the SDK's behavior parsing fractional second
epoch values with exponents.
  • Loading branch information
jasdel committed May 5, 2020
1 parent b39620e commit 2bd8cb4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions private/protocol/timestamp_test.go
Expand Up @@ -45,6 +45,11 @@ func TestParseTime(t *testing.T) {
formatName, input string
expectedOutput time.Time
}{
"UnixTestExponent": {
formatName: UnixTimeFormatName,
input: "1.583858715232899e9",
expectedOutput: time.Date(2020, time.March, 10, 16, 45, 15, .233e9, time.UTC),
},
"UnixTest1": {
formatName: UnixTimeFormatName,
input: "946845296.123",
Expand Down Expand Up @@ -81,10 +86,10 @@ func TestParseTime(t *testing.T) {
t.Run(name, func(t *testing.T) {
timeVal, err := ParseTime(c.formatName, c.input)
if err != nil {
t.Errorf("unable to parse time, %v", err)
t.Errorf("expect no error, got %v", err)
}
if timeVal.UTC() != c.expectedOutput {
t.Errorf("input and output time don't match for %s format ", c.formatName)
if e, a := c.expectedOutput, timeVal.UTC(); !e.Equal(a) {
t.Errorf("expect %v time, got %v", e, a)
}
})
}
Expand Down

0 comments on commit 2bd8cb4

Please sign in to comment.