...
1// Copyright 2011 The Go Authors. 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 deepequal_test
6
7import (
8 "testing"
9 "google3/spam/archer/frontend/deepequal"
10)
11
12func TestTwoNilValues(t *testing.T) {
13 if err := deepequal.Check(nil, nil); err != nil {
14 t.Errorf("expected nil, saw %v", err)
15 }
16}
17
18type Foo struct {
19 bar *Bar
20 bang *Bar
21}
22
23type Bar struct {
24 baz *Baz
25 foo []*Foo
26}
27
28type Baz struct {
29 entries map[int]interface{}
30 whatever string
31}
32
33func newFoo() (*Foo) {
34return &Foo{bar: &Bar{ baz: &Baz{
35entries: map[int]interface{}{
3642: &Foo{},
3721: &Bar{},
3811: &Baz{ whatever: "it's just a test" }}}},
39 bang: &Bar{foo: []*Foo{
40&Foo{bar: &Bar{ baz: &Baz{
41entries: map[int]interface{}{
4243: &Foo{},
4322: &Bar{},
4413: &Baz{ whatever: "this is nuts" }}}},
45 bang: &Bar{foo: []*Foo{
46&Foo{bar: &Bar{ baz: &Baz{
47entries: map[int]interface{}{
4861: &Foo{},
4971: &Bar{},
5011: &Baz{ whatever: "no, it's Go" }}}},
51 bang: &Bar{foo: []*Foo{
52&Foo{bar: &Bar{ baz: &Baz{
53entries: map[int]interface{}{
540: &Foo{},
55-2: &Bar{},
56-11: &Baz{ whatever: "we need to go deeper" }}}},
57 bang: &Bar{foo: []*Foo{
58&Foo{bar: &Bar{ baz: &Baz{
59entries: map[int]interface{}{
60-2: &Foo{},
61-5: &Bar{},
62-7: &Baz{ whatever: "are you serious?" }}}},
63 bang: &Bar{foo: []*Foo{}}},
64&Foo{bar: &Bar{ baz: &Baz{
65entries: map[int]interface{}{
66-100: &Foo{},
6750: &Bar{},
6820: &Baz{ whatever: "na, not really ..." }}}},
69 bang: &Bar{foo: []*Foo{}}}}}}}}},
70&Foo{bar: &Bar{ baz: &Baz{
71entries: map[int]interface{}{
722: &Foo{},
731: &Bar{},
74-1: &Baz{ whatever: "... it's just a test." }}}},
75 bang: &Bar{foo: []*Foo{}}}}}}}}}
76}
77
78func TestElaborate(t *testing.T) {
79 a := newFoo()
80 b := newFoo()
81
82 if err := deepequal.Check(a, b); err != nil {
83 t.Errorf("expected nil, saw %v", err)
84 }
85}
View as plain text