diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/base/strings/string_util_unittest.cc | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/base/strings/string_util_unittest.cc')
-rw-r--r-- | chromium/base/strings/string_util_unittest.cc | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/chromium/base/strings/string_util_unittest.cc b/chromium/base/strings/string_util_unittest.cc index f1132b9be4e..b9be7fbfa84 100644 --- a/chromium/base/strings/string_util_unittest.cc +++ b/chromium/base/strings/string_util_unittest.cc @@ -12,6 +12,7 @@ #include <algorithm> #include <type_traits> +#include "base/bits.h" #include "base/stl_util.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" @@ -678,28 +679,28 @@ TEST(StringUtilTest, FormatBytesUnlocalized) { int64_t bytes; const char* expected; } cases[] = { - // Expected behavior: we show one post-decimal digit when we have - // under two pre-decimal digits, except in cases where it makes no - // sense (zero or bytes). - // Since we switch units once we cross the 1000 mark, this keeps - // the display of file sizes or bytes consistently around three - // digits. - {0, "0 B"}, - {512, "512 B"}, - {1024*1024, "1.0 MB"}, - {1024*1024*1024, "1.0 GB"}, - {10LL*1024*1024*1024, "10.0 GB"}, - {99LL*1024*1024*1024, "99.0 GB"}, - {105LL*1024*1024*1024, "105 GB"}, - {105LL*1024*1024*1024 + 500LL*1024*1024, "105 GB"}, - {~(1LL << 63), "8192 PB"}, - - {99*1024 + 103, "99.1 kB"}, - {1024*1024 + 103, "1.0 MB"}, - {1024*1024 + 205 * 1024, "1.2 MB"}, - {1024*1024*1024 + (927 * 1024*1024), "1.9 GB"}, - {10LL*1024*1024*1024, "10.0 GB"}, - {100LL*1024*1024*1024, "100 GB"}, + // Expected behavior: we show one post-decimal digit when we have + // under two pre-decimal digits, except in cases where it makes no + // sense (zero or bytes). + // Since we switch units once we cross the 1000 mark, this keeps + // the display of file sizes or bytes consistently around three + // digits. + {0, "0 B"}, + {512, "512 B"}, + {1024 * 1024, "1.0 MB"}, + {1024 * 1024 * 1024, "1.0 GB"}, + {10LL * 1024 * 1024 * 1024, "10.0 GB"}, + {99LL * 1024 * 1024 * 1024, "99.0 GB"}, + {105LL * 1024 * 1024 * 1024, "105 GB"}, + {105LL * 1024 * 1024 * 1024 + 500LL * 1024 * 1024, "105 GB"}, + {~(bits::LeftmostBit<int64_t>()), "8192 PB"}, + + {99 * 1024 + 103, "99.1 kB"}, + {1024 * 1024 + 103, "1.0 MB"}, + {1024 * 1024 + 205 * 1024, "1.2 MB"}, + {1024 * 1024 * 1024 + (927 * 1024 * 1024), "1.9 GB"}, + {10LL * 1024 * 1024 * 1024, "10.0 GB"}, + {100LL * 1024 * 1024 * 1024, "100 GB"}, }; for (const auto& i : cases) { |