Files
MuditaOS/module-utils/tar/test/test_tar.cpp
Lefucjusz 773f2c7eb1 [BH-2069] Update license URL in headers
Update outdated license file URL in
license headers across all project.
2024-09-18 11:53:01 +02:00

31 lines
823 B
C++

// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md
#include <catch2/catch.hpp>
#include <tar/tar.hpp>
constexpr auto test_tar_entries_count = 68;
std::filesystem::path get_test_data(const std::string &name)
{
const std::string path = __FILE__;
return std::filesystem::path{path.substr(0, path.rfind('/'))} / name;
}
TEST_CASE("iterator")
{
auto count{0};
for ([[maybe_unused]] const auto &entry : tar::iterator(get_test_data("test.tar"))) {
count++;
}
REQUIRE(count == test_tar_entries_count);
}
TEST_CASE("Unpack")
{
REQUIRE_NOTHROW(tar::unpack(get_test_data("test.tar")));
REQUIRE_NOTHROW(tar::unpack(get_test_data("test.tar"), "prefix"));
REQUIRE_THROWS(tar::unpack(""));
}