summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2022-10-16 10:16:29 +0200
committerJoel Rosdahl <joel@rosdahl.net>2022-10-16 10:50:10 +0200
commit4e1c615602eff875366a3374442a1e96937858a0 (patch)
tree6937006ebaadc3d0148463641ca754740facc1cf
parent46fcf1ef0b737522228db34d1e293b5221f08589 (diff)
downloadccache-4e1c615602eff875366a3374442a1e96937858a0.tar.gz
test: Simplify util::read_file_part test
-rw-r--r--unittest/test_util_file.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/unittest/test_util_file.cpp b/unittest/test_util_file.cpp
index cc677137..b1222b43 100644
--- a/unittest/test_util_file.cpp
+++ b/unittest/test_util_file.cpp
@@ -20,6 +20,7 @@
#include <util/Bytes.hpp>
#include <util/file.hpp>
+#include <util/string.hpp>
#include <third_party/doctest.h>
@@ -133,23 +134,19 @@ TEST_CASE("util::read_file<std::string> with UTF-16 little endian encoding")
TEST_CASE("util::read_file_part")
{
- auto arr_from_str = [](std::string_view str) {
- return util::Bytes(str.data(), str.size());
- };
-
CHECK(util::write_file("test", "banana"));
- CHECK(util::read_file_part<util::Bytes>("test", 0, 0) == arr_from_str(""));
+ CHECK(util::read_file_part<util::Bytes>("test", 0, 0) == util::to_span(""));
CHECK(util::read_file_part<util::Bytes>("test", 0, 6)
- == arr_from_str("banana"));
+ == util::to_span("banana"));
CHECK(util::read_file_part<util::Bytes>("test", 0, 1000)
- == arr_from_str("banana"));
+ == util::to_span("banana"));
- CHECK(util::read_file_part<util::Bytes>("test", 3, 0) == arr_from_str(""));
- CHECK(util::read_file_part<util::Bytes>("test", 3, 2) == arr_from_str("an"));
+ CHECK(util::read_file_part<util::Bytes>("test", 3, 0) == util::to_span(""));
+ CHECK(util::read_file_part<util::Bytes>("test", 3, 2) == util::to_span("an"));
CHECK(util::read_file_part<util::Bytes>("test", 3, 1000)
- == arr_from_str("ana"));
+ == util::to_span("ana"));
CHECK(util::read_file_part<util::Bytes>("test", 1000, 1000)
- == arr_from_str(""));
+ == util::to_span(""));
}