-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathhelper.go
29 lines (24 loc) · 1.05 KB
/
helper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package jsonassert
// noopHelperTT is used to wrap the Printer in the case that users pass in an
// Printer which does not implement a Helper() method. *testing.T does
// implement this method so it is believed that this utility will be largely
// unused.
type noopHelperTT struct {
Printer
}
// Helper does nothing, intentionally. See New(Printer).
func (*noopHelperTT) Helper() {
// Intentional NOOP
}
// deepEqualityPrinter is a utility Printer that lets the jsonassert package
// verify equality internally without affecting the external facing output,
// e.g. to verify where one potential candidate is matching or not.
type deepEqualityPrinter struct{ count int }
func (p *deepEqualityPrinter) Errorf(_ string, _ ...interface{}) { p.count++ }
func (p *deepEqualityPrinter) Helper() { /* Intentional NOOP */ }
func (a *Asserter) deepEqual(act, exp interface{}) bool {
p := &deepEqualityPrinter{count: 0}
deepEqualityAsserter := &Asserter{tt: p}
deepEqualityAsserter.pathassertf("", serialize(act), serialize(exp))
return p.count == 0
}