Skip to content

Commit

Permalink
test elements of moved container of interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
m-fila committed Sep 26, 2024
1 parent 7fe8f88 commit cd476f6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/unittests/interface_types.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "catch2/catch_test_macros.hpp"

#include "datamodel/ExampleHit.h"
#include "datamodel/MutableExampleMC.h"
#include "datamodel/ExampleHitCollection.h"
#include "datamodel/MutableExampleCluster.h"
#include "datamodel/TypeWithEnergy.h"
Expand Down Expand Up @@ -70,9 +72,15 @@ TEST_CASE("InterfaceTypes STL usage", "[interface-types][basics]") {
REQUIRE(counterMap[hit] == 2);
REQUIRE(counterMap[wrapper] == 2);

auto mc = MutableExampleMC{};
mc.energy() = 3.14f;

// check container of interfaces move constructor and direct initialization
auto interfaces = std::vector<TypeWithEnergy>{};
[[maybe_unused]] auto interfaces2 = std::vector<TypeWithEnergy>{std::move(interfaces)};
auto interfaces = std::vector<TypeWithEnergy>{empty, hit, mc};
auto interfaces2 = std::vector<TypeWithEnergy>{std::move(interfaces)};
REQUIRE_FALSE(interfaces2.at(0).isAvailable());
REQUIRE(interfaces2.at(1).isA<ExampleHit>());
REQUIRE(interfaces2.at(2).energy() == 3.14f);
}

TEST_CASE("InterfaceType from immutable", "[interface-types][basics]") {
Expand Down

0 comments on commit cd476f6

Please sign in to comment.