~aleteoryx/muditaos

ref: b95894a8abc10cddf0b58dda4b2569b01eec0d7e muditaos/module-utils/tar/test/test_tar.cpp -rw-r--r-- 811 bytes
b95894a8 — Lefucjusz [MOS-1064] Fix no input language selected for French/Spanish 1 year, 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/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(""));
}