Skip to content

Instantly share code, notes, and snippets.

@jml
Created November 22, 2016 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jml/11af86b84a2107f08e441af91e597817 to your computer and use it in GitHub Desktop.
Save jml/11af86b84a2107f08e441af91e597817 to your computer and use it in GitHub Desktop.
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