Skip to content

Commit

Permalink
For HD Product name, use GiB unit from 10,000 Mib and higher. (#1147)
Browse files Browse the repository at this point in the history
* For HD Product name, use GiB unit from 10,000 Mib and higher.

* Update unit test
  • Loading branch information
rdmark authored Apr 20, 2023
1 parent 8dd5071 commit 3cceb51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions cpp/devices/scsihd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ string SCSIHD::GetProductData() const
uint64_t capacity = GetBlockCount() * GetSectorSizeInBytes();
string unit;

// 10 GiB and more
if (capacity >= 1'099'511'627'776) {
capacity /= 1'099'511'627'776;
// 10,000 MiB and more
if (capacity >= 10'485'760'000) {
capacity /= 1'073'741'824;
unit = "GiB";
}
// 1 MiB and more
Expand Down
4 changes: 2 additions & 2 deletions cpp/test/scsihd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ TEST(ScsiHdTest, GetProductData)

hd_gb.SetFilename(string(filename));
hd_gb.SetSectorSizeInBytes(1024);
hd_gb.SetBlockCount(1'099'511'627'776 / 1024);
hd_gb.SetBlockCount(10'737'418'240 / 1024);
hd_gb.FinalizeSetup(0);
s = hd_gb.GetProduct();
EXPECT_NE(string::npos, s.find("1 GiB"));
EXPECT_NE(string::npos, s.find("10 GiB"));
remove(filename);
}

Expand Down

0 comments on commit 3cceb51

Please sign in to comment.