AU: Fix unittest failure.
Seems that using floats/logs to find the number of digits can err on
some platforms. Switch to using ints.
BUG=chromium-os:17086
TEST=unittest
Change-Id: I0b1c83dcaa65ad2971049806be4cac0da8e9e306
Reviewed-on: http://gerrit.chromium.org/gerrit/3332
Reviewed-by: Scott Zawalski <scottz@chromium.org>
Tested-by: Andrew de los Reyes <adlr@chromium.org>
diff --git a/omaha_hash_calculator_unittest.cc b/omaha_hash_calculator_unittest.cc
index 28dc030..b6e03a4 100644
--- a/omaha_hash_calculator_unittest.cc
+++ b/omaha_hash_calculator_unittest.cc
@@ -72,10 +72,15 @@
TEST(OmahaHashCalculatorTest, BigTest) {
OmahaHashCalculator calc;
+ int digit_count = 1;
+ int next_overflow = 10;
for (int i = 0; i < 1000000; i++) {
char buf[8];
- ASSERT_EQ(0 == i ? 1 : static_cast<int>(floorf(logf(i) / logf(10))) + 1,
- snprintf(buf, sizeof(buf), "%d", i)) << " i = " << i;
+ if (i == next_overflow) {
+ next_overflow *= 10;
+ digit_count++;
+ }
+ ASSERT_EQ(digit_count, snprintf(buf, sizeof(buf), "%d", i)) << " i = " << i;
calc.Update(buf, strlen(buf));
}
calc.Finalize();