Skip to content

Commit

Permalink
osmomath: disable thelper for some helper functions (#5164)
Browse files Browse the repository at this point in the history
* mark helper functions

* disable thelper warnings
  • Loading branch information
pysel authored May 13, 2023
1 parent f60b062 commit 13c81d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions osmomath/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,12 +887,16 @@ func MaxDec(d1, d2 BigDec) BigDec {

// DecEq returns true if two given decimals are equal.
// Intended to be used with require/assert: require.True(t, DecEq(...))
//
//nolint:thelper
func DecEq(t *testing.T, exp, got BigDec) (*testing.T, bool, string, string, string) {
return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String()
}

// DecApproxEq returns true if the differences between two given decimals are smaller than the tolerance range.
// Intended to be used with require/assert: require.True(t, DecEq(...))
//
//nolint:thelper
func DecApproxEq(t *testing.T, d1 BigDec, d2 BigDec, tol BigDec) (*testing.T, bool, string, string, string) {
diff := d1.Sub(d2).Abs()
return t, diff.LTE(tol), "expected |d1 - d2| <:\t%v\ngot |d1 - d2| = \t\t%v", tol.String(), diff.String()
Expand Down
2 changes: 2 additions & 0 deletions osmomath/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ func (i BigInt) MarshalAmino() ([]byte, error) { return i.Marshal() }
func (i *BigInt) UnmarshalAmino(bz []byte) error { return i.Unmarshal(bz) }

// intended to be used with require/assert: require.True(IntEq(...))
//
//nolint:thelper
func IntEq(t *testing.T, exp, got BigInt) (*testing.T, bool, string, string, string) {
return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String()
}

0 comments on commit 13c81d8

Please sign in to comment.