Debian Codegraph @

tests/src/test_swinfo.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #include <catch2/catch_all.hpp>
5
6 #include "core/info/swinfo.h"
7
8 namespace Tests::SWInfo {
9
10 class ProviderStub : public ISWInfo::IProvider
11 {
12 public:
13 std::vector<std::pair<std::string, std::string>> provideInfo() const override
14 {
15 std::vector<std::pair<std::string, std::string>> info;
16 info.emplace_back("info_key", "info");
17 return info;
18 }
19 };
20
21 TEST_CASE("SWInfo tests", "[Info][SWInfo]")
22 {
23 ::SWInfo ts;
24
25 SECTION("Software info is collected on initialization")
26 {
27 REQUIRE(ts.keys().empty());
28
29 std::vector<std::unique_ptr<ISWInfo::IProvider>> providers;
30 providers.emplace_back(std::make_unique<ProviderStub>());
31
32 ts.initialize(providers);
33 auto keys = ts.keys();
34
35 REQUIRE(keys.size() == 1);
36 REQUIRE(keys.front() == "info_key");
37 REQUIRE(ts.info("info_key") == "info");
38 }
39 }
40
41 } // namespace Tests::SWInfo