1// Copyright 2014 Google Inc.  All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package uuid
6
7import (
8	"encoding/json"
9	"reflect"
10	"testing"
11)
12
13var testUUID = Parse("f47ac10b-58cc-0372-8567-0e02b2c3d479")
14
15func TestJSON(t *testing.T) {
16	type S struct {
17		ID1 UUID
18		ID2 UUID
19	}
20	s1 := S{ID1: testUUID}
21	data, err := json.Marshal(&s1)
22	if err != nil {
23		t.Fatal(err)
24	}
25	var s2 S
26	if err := json.Unmarshal(data, &s2); err != nil {
27		t.Fatal(err)
28	}
29	if !reflect.DeepEqual(&s1, &s2) {
30		t.Errorf("got %#v, want %#v", s2, s1)
31	}
32}
33