Skip to content

Commit

Permalink
Correct maximum precision corner case
Browse files Browse the repository at this point in the history
  • Loading branch information
Gus Carreon authored and Gus Carreon committed Oct 15, 2020
1 parent 388a8a0 commit 0ecbfed
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions exchange/price_granularity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ func TestGetPriceBucketString(t *testing.T) {
"2",
},
{
"Largest precision value PBS supports (2^15 = 32768)",
openrtb_ext.PriceGranularity{Precision: int(math.Pow(2, 15)), Ranges: []openrtb_ext.GranularityRange{{Max: 5, Increment: 0.05}}},
"1.85000000000000008881784",
"Largest precision value PBS supports 15",
openrtb_ext.PriceGranularity{Precision: 15, Ranges: []openrtb_ext.GranularityRange{{Max: 5, Increment: 0.05}}},
"1.850000000000000",
},
},
},
Expand Down Expand Up @@ -130,6 +130,7 @@ func TestGetPriceBucketString(t *testing.T) {
priceBucket := GetPriceBucket(testGroup.cpm, test.granularity)

assert.True(t, strings.HasPrefix(priceBucket, test.expectedPriceBucket), "Group: %s Granularity: %s :: Expected %s, got %s from %f", testGroup.groupDesc, test.granularityId, test.expectedPriceBucket, priceBucket, testGroup.cpm)
assert.Equal(t, test.expectedPriceBucket, priceBucket, "Group: %s Granularity: %s :: Expected %s, got %s from %f", testGroup.groupDesc, test.granularityId, test.expectedPriceBucket, priceBucket, testGroup.cpm)
}
}
}

0 comments on commit 0ecbfed

Please sign in to comment.