Skip to content

Commit

Permalink
Add static checks to unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Feb 13, 2024
1 parent 202f2db commit 209e08a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/unittests/unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
#include "datamodel/ExampleWithOneRelationCollection.h"
#include "datamodel/ExampleWithUserInitCollection.h"
#include "datamodel/ExampleWithVectorMemberCollection.h"
#include "datamodel/MutableExampleCluster.h"
#include "datamodel/MutableExampleWithArray.h"
#include "datamodel/MutableExampleWithComponent.h"
#include "podio/UserDataCollection.h"

Expand Down Expand Up @@ -356,7 +358,7 @@ TEST_CASE("Arrays") {
}
*/

TEST_CASE("member getter return types", "[basics][code-gen]") {
TEST_CASE("member getter return types", "[basics][code-gen][const-correctness]") {
// Check that the return types of the getter functions are as expected
// Builtin member types are returned by value, including fixed width integers
STATIC_REQUIRE(std::is_same_v<decltype(std::declval<ExampleHit>().energy()), double>);
Expand All @@ -372,6 +374,13 @@ TEST_CASE("member getter return types", "[basics][code-gen]") {
STATIC_REQUIRE(std::is_same_v<decltype(std::declval<ExampleWithArrayComponent>().x()), int>);
STATIC_REQUIRE(std::is_same_v<decltype(std::declval<ExampleWithArrayComponent>().p()), const std::array<int, 4>&>);
STATIC_REQUIRE(std::is_same_v<decltype(std::declval<ExampleWithArray>().data()), const SimpleStruct&>);

// Mutable types also give access to mutable references
STATIC_REQUIRE(std::is_same_v<decltype(std::declval<MutableExampleCluster>().energy()), double&>);
STATIC_REQUIRE(std::is_same_v<decltype(std::declval<MutableExampleWithArray>().data()), SimpleStruct&>);
// However if they are const the usual rules apply
STATIC_REQUIRE(std::is_same_v<decltype(std::declval<const MutableExampleCluster>().energy()), double>);
STATIC_REQUIRE(std::is_same_v<decltype(std::declval<const MutableExampleWithArray>().data()), const SimpleStruct&>);
}

TEST_CASE("Extracode", "[basics][code-gen]") {
Expand Down

0 comments on commit 209e08a

Please sign in to comment.