Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type T ¶
T is the testing helper. Most notably it provides T.Equal
func (T) Equal ¶
Equal reports whether want and got are deeply equal.
Unlike reflect.DeepEqual it first recursively checks exported fields and "getters", which are defined as an exported method with:
- exactly zero input arguments
- exactly one return value
- does not start with 'Append'
If this yields differences, those are reported and the test fails. If the compared values are [pmetric.ExponentialHistogramDataPoint], then pmetrictest.CompareExponentialHistogramDataPoint is also called.
If no differences are found, it falls back to [assert.Equal].
This was done to aid readability when comparing deeply nested [pmetric]/[pcommon] types, because in many cases [assert.Equal] output was found to be barely understandable.
Example ¶
is := datatest.New(t) want := expotest.Histogram{ PosNeg: expotest.Observe(expo.Scale(0), 1, 2, 3, 4), Scale: 0, }.Into() got := expotest.Histogram{ PosNeg: expotest.Observe(expo.Scale(1), 1, 1, 1, 1), Scale: 1, }.Into() is.Equal(want, got)
Output: equal_test.go:55: Negative().BucketCounts().AsRaw(): [1 1 2] != [4] equal_test.go:55: Negative().BucketCounts().Len(): 3 != 1 equal_test.go:55: Positive().BucketCounts().AsRaw(): [1 1 2] != [4] equal_test.go:55: Positive().BucketCounts().Len(): 3 != 1 equal_test.go:55: Scale(): 0 != 1