Skip to content

Commit

Permalink
[wip] Make tests compile again
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Nov 10, 2023
1 parent 0d55afb commit fab066a
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 62 deletions.
2 changes: 1 addition & 1 deletion tests/ostream_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int main(int, char**) {
// Non-cyclical references
MutableExampleReferencingType ref1;
MutableExampleReferencingType ref2;
ExampleReferencingType ref3;
MutableExampleReferencingType ref3;

ref1.addRefs(ref2);
ref2.addRefs(ref3);
Expand Down
6 changes: 3 additions & 3 deletions tests/read_python_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ int checkHits(const ExampleHitCollection& hits) {

auto hit1 = hits[0];
if (hit1.cellID() != 0xbad || hit1.x() != 0.0 || hit1.y() != 0.0 || hit1.z() != 0.0 || hit1.energy() != 23.0) {
std::cerr << "Could not retrieve the correct hit[0]: (expected: " << ExampleHit(0xbad, 0.0, 0.0, 0.0, 23.0)
std::cerr << "Could not retrieve the correct hit[0]: (expected: " << MutableExampleHit(0xbad, 0.0, 0.0, 0.0, 23.0)
<< ", actual: " << hit1 << ")" << std::endl;
return 1;
}

auto hit2 = hits[1];
if (hit2.cellID() != 0xcaffee || hit2.x() != 1.0 || hit2.y() != 0.0 || hit2.z() != 0.0 || hit2.energy() != 12.0) {
std::cerr << "Could not retrieve the correct hit[1]: (expected: " << ExampleHit(0xcaffee, 1.0, 0.0, 0.0, 12.0)
<< ", actual: " << hit1 << ")" << std::endl;
std::cerr << "Could not retrieve the correct hit[1]: (expected: "
<< MutableExampleHit(0xcaffee, 1.0, 0.0, 0.0, 12.0) << ", actual: " << hit1 << ")" << std::endl;
return 1;
}

Expand Down
7 changes: 2 additions & 5 deletions tests/root_io/read_and_write_associated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ void writeCollection() {
event.putParameter("UserEventName", std::to_string(i));

auto hits = ExampleHitCollection{};
auto hit1 = ExampleHit(0xbad, 0., 0., 0., 23. + i);
auto hit2 = ExampleHit(0xcaffee, 1., 0., 0., 12. + i);

hits.push_back(hit1);
hits.push_back(hit2);
auto hit1 = hits.create(0xbad, 0., 0., 0., 23. + i);
auto hit2 = hits.create(0xcaffee, 1., 0., 0., 12. + i);

// Clusters
auto clusters = ExampleClusterCollection{};
Expand Down
4 changes: 2 additions & 2 deletions tests/root_io/relation_range.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ void testExampleWithVectorMember() {

void testExampleReferencingType() {
MutableExampleReferencingType ex;
ExampleReferencingType ex1;
ExampleReferencingType ex2;
MutableExampleReferencingType ex1;
MutableExampleReferencingType ex2;

ex.addRefs(ex1);
ex.addRefs(ex2);
Expand Down
30 changes: 16 additions & 14 deletions tests/unittests/unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "catch2/catch_test_macros.hpp"

// podio specific includes
#include "datamodel/MutableExampleHit.h"
#include "podio/EventStore.h"
#include "podio/GenericParameters.h"
#include "podio/ROOTFrameReader.h"
Expand Down Expand Up @@ -66,9 +67,9 @@ TEST_CASE("Assignment-operator ref count", "[basics][memory-management]") {
// Make sure that the assignment operator handles the reference count
// correctly. (Will trigger in an ASan build if it is not the case)
// See https://github.com/AIDASoft/podio/issues/200
std::map<int, ExampleHit> hitMap;
std::map<int, MutableExampleHit> hitMap;
for (int i = 0; i < 10; ++i) {
auto hit = ExampleHit(0x42ULL, i, i, i, i);
auto hit = MutableExampleHit(0x42ULL, i, i, i, i);
hitMap[i] = hit;
}

Expand All @@ -89,7 +90,7 @@ TEST_CASE("Clearing", "[UBSAN-FAIL][ASAN-FAIL][THREAD-FAIL][basics][memory-manag
hits.clear();
clusters.clear();
auto hit1 = hits.create();
auto hit2 = ExampleHit();
auto hit2 = MutableExampleHit();
hit1.energy(double(i));
auto cluster = clusters.create();
cluster.addHits(hit1);
Expand Down Expand Up @@ -118,7 +119,8 @@ TEST_CASE("Cloning", "[basics][memory-management]") {
auto cluster2 = cluster.clone();
cluster.addHits(hit2);
// check that the clone of a const object is mutable
auto const_hit = ExampleHit();
auto mutable_hit = MutableExampleHit();
auto const_hit = ExampleHit(mutable_hit);
auto const_hit_clone = const_hit.clone();
const_hit_clone.energy(30);
REQUIRE(success);
Expand Down Expand Up @@ -150,7 +152,7 @@ TEST_CASE("Invalid_refs", "[LEAK-FAIL][basics][relations]") {
auto store = podio::EventStore();
auto& hits = store.create<ExampleHitCollection>("hits");
auto hit1 = hits.create(0xcaffeeULL, 0., 0., 0., 0.);
auto hit2 = ExampleHit();
auto hit2 = MutableExampleHit();
auto& clusters = store.create<ExampleClusterCollection>("clusters");
auto cluster = clusters.create();
cluster.addHits(hit1);
Expand Down Expand Up @@ -208,7 +210,7 @@ TEST_CASE("Notebook", "[basics]") {

TEST_CASE("OneToOneRelations", "[basics][relations]") {
bool success = true;
auto cluster = ExampleCluster();
auto cluster = MutableExampleCluster();
auto rel = MutableExampleWithOneRelation();
rel.cluster(cluster);
REQUIRE(success);
Expand Down Expand Up @@ -361,11 +363,11 @@ TEST_CASE("Extracode", "[basics][code-gen]") {
}

TEST_CASE("AssociativeContainer", "[basics]") {
auto clu1 = ExampleCluster();
auto clu2 = ExampleCluster();
auto clu3 = ExampleCluster();
auto clu4 = ExampleCluster();
auto clu5 = ExampleCluster();
auto clu1 = MutableExampleCluster();
auto clu2 = MutableExampleCluster();
auto clu3 = MutableExampleCluster();
auto clu4 = MutableExampleCluster();
auto clu5 = MutableExampleCluster();

std::set<ExampleCluster> cSet;
cSet.insert(clu1);
Expand Down Expand Up @@ -396,7 +398,7 @@ TEST_CASE("AssociativeContainer", "[basics]") {
}

TEST_CASE("Equality", "[basics]") {
auto cluster = ExampleCluster();
auto cluster = MutableExampleCluster();
auto rel = MutableExampleWithOneRelation();
rel.cluster(cluster);
auto returned_cluster = rel.cluster();
Expand All @@ -419,7 +421,7 @@ TEST_CASE("UserInitialization", "[basics][code-gen]") {
REQUIRE(elem.comp().arr[1] == 3.4);

// And obviously when initialized directly
auto ex = ExampleWithUserInit{};
auto ex = MutableExampleWithUserInit{};
REQUIRE(ex.i16Val() == 42);
REQUIRE(ex.floats()[0] == 3.14f);
REQUIRE(ex.floats()[1] == 1.23f);
Expand Down Expand Up @@ -620,7 +622,7 @@ TEST_CASE("Cannot convert a subset collection into a normal collection", "[subse
TEST_CASE("Subset collection only handles tracked objects", "[subset-colls]") {
auto clusterRefs = ExampleClusterCollection();
clusterRefs.setSubsetCollection();
auto cluster = ExampleCluster();
auto cluster = MutableExampleCluster();

REQUIRE_THROWS_AS(clusterRefs.push_back(cluster), std::invalid_argument);
REQUIRE_THROWS_AS(clusterRefs.create(), std::logic_error);
Expand Down
28 changes: 14 additions & 14 deletions tests/write_ascii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,23 @@ int main() {
auto item1 = MutableEventInfo();
item1.Number(i);
info.push_back(item1);
auto hit1 = ExampleHit(0xbad, 0., 0., 0., 23. + i);
auto hit2 = ExampleHit(0xcaffee, 1., 0., 0., 12. + i);
auto hit1 = MutableExampleHit(0xbad, 0., 0., 0., 23. + i);
auto hit2 = MutableExampleHit(0xcaffee, 1., 0., 0., 12. + i);

hits.push_back(hit1);
hits.push_back(hit2);

// ---- add some MC particles ----
auto mcp0 = ExampleMC();
auto mcp1 = ExampleMC();
auto mcp2 = ExampleMC();
auto mcp3 = ExampleMC();
auto mcp4 = ExampleMC();
auto mcp5 = ExampleMC();
auto mcp6 = ExampleMC();
auto mcp7 = ExampleMC();
auto mcp8 = ExampleMC();
auto mcp9 = ExampleMC();
auto mcp0 = MutableExampleMC();
auto mcp1 = MutableExampleMC();
auto mcp2 = MutableExampleMC();
auto mcp3 = MutableExampleMC();
auto mcp4 = MutableExampleMC();
auto mcp5 = MutableExampleMC();
auto mcp6 = MutableExampleMC();
auto mcp7 = MutableExampleMC();
auto mcp8 = MutableExampleMC();
auto mcp9 = MutableExampleMC();

mcps.push_back(mcp0);
mcps.push_back(mcp1);
Expand Down Expand Up @@ -154,7 +154,7 @@ int main() {
auto ref = MutableExampleReferencingType();
refs.push_back(ref);

auto ref2 = ExampleReferencingType();
auto ref2 = MutableExampleReferencingType();
refs2.push_back(ref2);

ref.addClusters(cluster);
Expand All @@ -175,7 +175,7 @@ int main() {
oneRels.push_back(oneRel);

// write non-filled relation
auto oneRelEmpty = ExampleWithOneRelation();
auto oneRelEmpty = MutableExampleWithOneRelation();
oneRels.push_back(oneRelEmpty);

auto vec = MutableExampleWithVectorMember();
Expand Down
13 changes: 4 additions & 9 deletions tests/write_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,8 @@ auto createMCRefCollection(const ExampleMCCollection& mcps, const ExampleMCColle
auto createHitCollection(int i) {
ExampleHitCollection hits;

auto hit1 = ExampleHit(0xbad, 0., 0., 0., 23. + i);
auto hit2 = ExampleHit(0xcaffee, 1., 0., 0., 12. + i);

hits.push_back(hit1);
hits.push_back(hit2);
auto hit1 = hits.create(0xbad, 0., 0., 0., 23. + i);
auto hit2 = hits.create(0xcaffee, 1., 0., 0., 12. + i);

return hits;
}
Expand Down Expand Up @@ -173,8 +170,7 @@ auto createReferencingCollections(const ExampleClusterCollection& clusters) {
auto ref = MutableExampleReferencingType();
refs.push_back(ref);

auto ref2 = ExampleReferencingType();
refs2.push_back(ref2);
auto ref2 = refs2.create();

ref.addClusters(clusters[2]);
ref.addRefs(ref2);
Expand All @@ -194,8 +190,7 @@ auto createOneRelCollection(const ExampleClusterCollection& clusters) {
oneRels.push_back(oneRel);

// write non-filled relation
auto oneRelEmpty = ExampleWithOneRelation();
oneRels.push_back(oneRelEmpty);
oneRels.create();

return oneRels;
}
Expand Down
28 changes: 14 additions & 14 deletions tests/write_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ void write(podio::EventStore& store, WriterT& writer) {
auto& colMD = store.getCollectionMetaData(hits.getID());
colMD.setValue("CellIDEncodingString", "system:8,barrel:3,layer:6,slice:5,x:-16,y:-16");

auto hit1 = ExampleHit(0xbad, 0., 0., 0., 23. + i);
auto hit2 = ExampleHit(0xcaffee, 1., 0., 0., 12. + i);
auto hit1 = MutableExampleHit(0xbad, 0., 0., 0., 23. + i);
auto hit2 = MutableExampleHit(0xcaffee, 1., 0., 0., 12. + i);

hits.push_back(hit1);
hits.push_back(hit2);
Expand All @@ -102,16 +102,16 @@ void write(podio::EventStore& store, WriterT& writer) {
hitRefs.push_back(hit1);

// ---- add some MC particles ----
auto mcp0 = ExampleMC();
auto mcp1 = ExampleMC();
auto mcp2 = ExampleMC();
auto mcp3 = ExampleMC();
auto mcp4 = ExampleMC();
auto mcp5 = ExampleMC();
auto mcp6 = ExampleMC();
auto mcp7 = ExampleMC();
auto mcp8 = ExampleMC();
auto mcp9 = ExampleMC();
auto mcp0 = MutableExampleMC();
auto mcp1 = MutableExampleMC();
auto mcp2 = MutableExampleMC();
auto mcp3 = MutableExampleMC();
auto mcp4 = MutableExampleMC();
auto mcp5 = MutableExampleMC();
auto mcp6 = MutableExampleMC();
auto mcp7 = MutableExampleMC();
auto mcp8 = MutableExampleMC();
auto mcp9 = MutableExampleMC();

mcps.push_back(mcp0);
mcps.push_back(mcp1);
Expand Down Expand Up @@ -227,7 +227,7 @@ void write(podio::EventStore& store, WriterT& writer) {
auto ref = MutableExampleReferencingType();
refs.push_back(ref);

auto ref2 = ExampleReferencingType();
auto ref2 = MutableExampleReferencingType();
refs2.push_back(ref2);

ref.addClusters(cluster);
Expand All @@ -248,7 +248,7 @@ void write(podio::EventStore& store, WriterT& writer) {
oneRels.push_back(oneRel);

// write non-filled relation
auto oneRelEmpty = ExampleWithOneRelation();
auto oneRelEmpty = MutableExampleWithOneRelation();
oneRels.push_back(oneRelEmpty);

auto vec = MutableExampleWithVectorMember();
Expand Down

0 comments on commit fab066a

Please sign in to comment.