Lines Matching +full:x +full:- +full:real +full:- +full:ip
2 // Use of this source code is governed by a BSD-style
16 "github.com/google/go-cmp/cmp"
19 // TODO: Re-write these examples in terms of how you actually use the
23 // Use Diff to print out a human-readable report of differences for tests
31 t.Errorf("MakeGatewayInfo() mismatch (-want +got):\n%s", diff)
35 // MakeGatewayInfo() mismatch (-want +got):
38 // - IPAddress: s"192.168.0.2",
43 …// {Hostname: "macchiato", IPAddress: s"192.168.0.153", LastSeen: s"2009-11-10 23:39:43 +0000 …
47 // - IPAddress: s"192.168.0.221",
49 // LastSeen: s"2009-11-10 23:00:23 +0000 UTC",
54 // + LastSeen: s"2009-11-10 23:03:05 +0000 UTC",
69 opt := cmp.Comparer(func(x, y float64) bool {
70 delta := math.Abs(x - y)
71 mean := math.Abs(x+y) / 2.0
75 x := []float64{1.0, 1.1, 1.2, math.Pi}
79 fmt.Println(cmp.Equal(x, y, opt))
81 fmt.Println(cmp.Equal(z, x, opt))
89 // Normal floating-point arithmetic defines == to be false when comparing
97 opt := cmp.Comparer(func(x, y float64) bool {
98 return (math.IsNaN(x) && math.IsNaN(y)) || x == y
101 x := []float64{1.0, math.NaN(), math.E, 0.0}
105 fmt.Println(cmp.Equal(x, y, opt))
107 fmt.Println(cmp.Equal(z, x, opt))
115 // To have floating-point comparisons combine both properties of NaN being
127 cmp.FilterValues(func(x, y float64) bool {
128 return math.IsNaN(x) && math.IsNaN(y)
133 cmp.FilterValues(func(x, y float64) bool {
134 return !math.IsNaN(x) && !math.IsNaN(y)
135 }, cmp.Comparer(func(x, y float64) bool {
136 delta := math.Abs(x - y)
137 mean := math.Abs(x+y) / 2.0
142 x := []float64{math.NaN(), 1.0, 1.1, 1.2, math.Pi}
146 fmt.Println(cmp.Equal(x, y, opts))
148 fmt.Println(cmp.Equal(z, x, opts))
164 opt := cmp.FilterValues(func(x, y interface{}) bool {
165 vx, vy := reflect.ValueOf(x), reflect.ValueOf(y)
175 x := S{nil, make(map[string]bool, 100)}
179 fmt.Println(cmp.Equal(x, y, opt))
181 fmt.Println(cmp.Equal(z, x, opt))
202 x := struct{ Ints []int }{[]int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}}
206 fmt.Println(cmp.Equal(x, y, trans))
208 fmt.Println(cmp.Equal(z, x, trans))
218 func (x otherString) Equal(y otherString) bool {
219 return strings.EqualFold(string(x), string(y))
226 // Suppose otherString.Equal performs a case-insensitive equality,
237 x := []otherString{"foo", "bar", "baz"}
240 fmt.Println(cmp.Equal(x, y)) // Equal because of case-insensitivity
241 fmt.Println(cmp.Equal(x, y, trans)) // Not equal because of more exact equality
250 return math.Ceil(z - 0.5)
263 cmp.Transformer("T1", func(in complex128) (out struct{ Real, Imag float64 }) {
264 out.Real, out.Imag = real(in), imag(in)
277 cmp.Comparer(func(x, y float64) bool {
278 return roundF64(x) == roundF64(y)
282 x := []interface{}{
283 complex128(3.0), complex64(5.1 + 2.9i), float32(-1.2), float64(12.3),
286 complex128(3.1), complex64(4.9 + 3.1i), float32(-1.3), float64(11.7),
289 complex128(3.8), complex64(4.9 + 3.1i), float32(-1.3), float64(11.7),
292 fmt.Println(cmp.Equal(x, y, opts...))
294 fmt.Println(cmp.Equal(z, x, opts...))
305 IPAddress net.IP
311 IPAddress net.IP
316 func MakeGatewayInfo() (x, y Gateway) {
317 x = Gateway{
369 return x, y