Improve conversion of bytes to human readable string
Fixes issues like showing 0 MiB when the value is just slightly less then 1 MiB.
This commit is contained in:
parent
db2594a87c
commit
5bdd3fa95d
7 changed files with 125 additions and 44 deletions
23
tests/pglabtests/tst_HumanReadableBytes.cpp
Normal file
23
tests/pglabtests/tst_HumanReadableBytes.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <gmock/gmock-matchers.h>
|
||||
#include "PrintTo_Qt.h"
|
||||
|
||||
#include "utils/HumanReadableBytes.h"
|
||||
|
||||
TEST(HumanReadableBytesTest, bytes7)
|
||||
{
|
||||
auto s = HumanReadableBytes(7);
|
||||
ASSERT_EQ("7 B", s);
|
||||
}
|
||||
|
||||
TEST(HumanReadableBytesTest, bytes1023)
|
||||
{
|
||||
auto s = HumanReadableBytes(1023);
|
||||
ASSERT_EQ("1023 B", s);
|
||||
}
|
||||
|
||||
TEST(HumanReadableBytesTest, bytes1k)
|
||||
{
|
||||
auto s = HumanReadableBytes(1024);
|
||||
ASSERT_EQ("1.00 kiB", s);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue