Skip to content

Commit

Permalink
fix(lokicompliance): convert fpoint strings to floats
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Apr 18, 2024
1 parent 22cc5a5 commit e1f28e5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/lokicompliance/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ func addFloatCompareOptions(options *cmp.Options) {
*options = append(
*options,
cmpopts.EquateApprox(fraction, margin),
// Translate sample values into float64 so that cmpopts.EquateApprox() works.
cmp.Transformer("TranslateFloat64", func(in lokiapi.FPoint) float64 {
v, _ := strconv.ParseFloat(in.V, 64)
return v
}),
// A NaN is usually not treated as equal to another NaN, but we want to treat it as such here.
cmpopts.EquateNaNs(),
)
Expand Down

0 comments on commit e1f28e5

Please sign in to comment.