Created
November 22, 2016 15:16
-
-
Save jml/11af86b84a2107f08e441af91e597817 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"testing" | |
"time" | |
"github.com/stretchr/testify/assert" | |
"github.com/stretchr/testify/require" | |
) | |
func Test_Time_Roundtrip(t *testing.T) { | |
var x time.Time | |
output, err := json.Marshal(x) | |
require.NoError(t, err, "Could not marshal time") | |
var y time.Time | |
err = json.Unmarshal(output, &y) | |
require.NoError(t, err, "Could not unmarshal time") | |
assert.Equal(t, x, y) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment