From fb1d2d12e33dc8691ff115d87701e5947040e03a Mon Sep 17 00:00:00 2001 From: Will Norris Date: Thu, 5 Sep 2013 13:23:46 -0700 Subject: [PATCH] test unmarshalling as well in testJSONMarshal() --- github/github_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/github/github_test.go b/github/github_test.go index bf4d87e..8612c3b 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -95,6 +95,16 @@ func testJSONMarshal(t *testing.T, v interface{}, want string) { if w.String() != string(j) { t.Errorf("json.Marshal(%q) returned %s, want %s", v, j, w) } + + // now go the other direction and make sure things unmarshal as expected + u := reflect.ValueOf(v).Interface() + if err := json.Unmarshal([]byte(want), u); err != nil { + t.Errorf("Unable to unmarshal JSON for %v", want) + } + + if !reflect.DeepEqual(v, u) { + t.Errorf("json.Unmarshal(%q) returned %s, want %s", want, u, v) + } } func TestNewClient(t *testing.T) {