mirror of
https://github.com/NixOS/nix.git
synced 2024-11-25 08:12:29 +00:00
renderSize(): Add some unit tests
This commit is contained in:
parent
cf3b044b7e
commit
f0b5628eb2
@ -421,6 +421,23 @@ namespace nix {
|
||||
ASSERT_EQ(string2Int<int>("-100"), -100);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* renderSize
|
||||
* --------------------------------------------------------------------------*/
|
||||
|
||||
TEST(renderSize, misc) {
|
||||
ASSERT_EQ(renderSize(0, true), " 0.0 KiB");
|
||||
ASSERT_EQ(renderSize(100, true), " 0.1 KiB");
|
||||
ASSERT_EQ(renderSize(100), "0.1 KiB");
|
||||
ASSERT_EQ(renderSize(972, true), " 0.9 KiB");
|
||||
ASSERT_EQ(renderSize(973, true), " 1.0 KiB"); // FIXME: should round down
|
||||
ASSERT_EQ(renderSize(1024, true), " 1.0 KiB");
|
||||
ASSERT_EQ(renderSize(1024 * 1024, true), "1024.0 KiB");
|
||||
ASSERT_EQ(renderSize(1100 * 1024, true), " 1.1 MiB");
|
||||
ASSERT_EQ(renderSize(2ULL * 1024 * 1024 * 1024, true), " 2.0 GiB");
|
||||
ASSERT_EQ(renderSize(2100ULL * 1024 * 1024 * 1024, true), " 2.1 TiB");
|
||||
}
|
||||
|
||||
#ifndef _WIN32 // TODO re-enable on Windows, once we can start processes
|
||||
/* ----------------------------------------------------------------------------
|
||||
* statusOk
|
||||
|
Loading…
Reference in New Issue
Block a user