v1.11.0
New features
JSON
,SubJSONOf
andSuperJSONOf
operators:- Now:
act the same way. Since v1.10.1 rework, the second was not working as expected.
td.JSON(`{"foo": $1}`, td.Between(12, 34)) td.JSON(`{"foo": Between($1, $2)}`, 12, 34)
At the same time:now works as expected. It was rejected before,td.JSON(`{"foo": Between(12, 34, $1)}`, td.BoundsOutIn)
int_lit
&float_lit
numbers, as defined in go specification, are now accepted in JSON, allowing, for example, to embed hexadecimal numbers in expected JSON;
- Now:
Between
operator acceptstime.Duration
asTO
whenFROM
is atime.Time
;Between
,Gt
,Gte
,Lt
andLte
operators:- now handle values implementing
Compare
orLess
methods:
Compare
and/orLess
methods signatures follow:for example, the new go1.18func (a T) Less(b T) bool // returns true if a < b func (a T) Compare(b T) int // returns -1 if a < b, 1 if a > b, 0 if a == b
net/netip.Addr
implements both, - failure reports display numbers as elsewhere,
- some docs have been fixed;
- now handle values implementing
Smuggle
can now cast values, allowing such things:// A string containing JSON got := `{ "foo": 123 }` td.Cmp(t, got, td.Smuggle(json.RawMessage{}, td.JSON(`{"foo":123}`)) // or td.Cmp(t, got, td.Smuggle((json.RawMessage)(nil), td.JSON(`{"foo":123}`))
- in report failures, the stack trace was displayed if it contained at least 2 levels. Now it is also displayed if it contains one level BUT the source file path contains a directory. It helps to localize quickly the errors in large repositories;
td.T
gains 3 new methods to log with a stack trace:LogTrace
,ErrorTrace
andFatalTrace
;- handle go1.17
[]T
→*[n]T
convertibility edge case; - in failure reports
(float64)
type is now omitted (like(int)
and(bool)
already were), but the value always contains a "." (except if±Inf
,NaN
or with exponent) to distinguish them fromint
.
Fixes
Contains
: slice in slice search didn't work at end of slice;JSON
,SubJSONOf
andSuperJSONOf
operators panicked when usingAll
+JSON-operator+embeddedOp+$1
;- anchoring 2 slices at the same time didn't work.
Miscellaneous
- CI build:
- now uses
install-go.pl
v3.0, sotip
test is very fast most of the time, - golangci-lint upgraded to v1.43.0,
- uses bidichk linter;
- now uses
//go:build
line added when// +build
was already present, since go1.17 changes;//nolint:
pragmas uniformized.
And happy new year!