From: Joel Rosdahl Date: Thu, 5 Jan 2023 18:14:17 +0000 (+0100) Subject: chore: Add unit tests for parsing size with (undocumented) B suffix X-Git-Tag: v4.8~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7eed47f937155a6c0b62d26739e1b65c4edc1f2;p=thirdparty%2Fccache.git chore: Add unit tests for parsing size with (undocumented) B suffix --- diff --git a/unittest/test_Util.cpp b/unittest/test_Util.cpp index a45d7c57a..e5bca40c2 100644 --- a/unittest/test_Util.cpp +++ b/unittest/test_Util.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2022 Joel Rosdahl and other contributors +// Copyright (C) 2019-2023 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -677,6 +677,9 @@ TEST_CASE("Util::parse_size") CHECK(Util::parse_size("2 Ti") == static_cast(2) * 1024 * 1024 * 1024 * 1024); + CHECK(Util::parse_size("9MB") == 9 * 1000 * 1000); + CHECK(Util::parse_size("9MiB") == 9 * 1024 * 1024); + CHECK_THROWS_WITH(Util::parse_size(""), "invalid size: \"\""); CHECK_THROWS_WITH(Util::parse_size("x"), "invalid size: \"x\""); CHECK_THROWS_WITH(Util::parse_size("10x"), "invalid size: \"10x\"");