From 36d06e63b6850e34dce9ea16a764e2429f080bb1 Mon Sep 17 00:00:00 2001 From: tmadlener Date: Tue, 12 Sep 2023 11:16:43 +0200 Subject: [PATCH] Add a test for a `float` to `double` migration --- tests/schema_evolution/README.md | 1 + tests/schema_evolution/datalayout_new.yaml | 2 +- tests/schema_evolution/read_new_data.h | 11 +++++++++++ tests/schema_evolution/write_old_data.h | 10 ++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/schema_evolution/README.md b/tests/schema_evolution/README.md index 92bd4a667..1c83fc3f6 100644 --- a/tests/schema_evolution/README.md +++ b/tests/schema_evolution/README.md @@ -17,3 +17,4 @@ tested (if it is supported) | `SimpleStruct` | no `int t` member in v2 | Addition of new members in components | As member of `ExampleWithArrayComponent` | | `ExampleHit` | no `double t` member in v1 | Addition of new members in datatypes | Directly via `ExampleHit` | | `ex2::NamespaceStruct` | renaming of `y` to `y_new` | Renaming of member variables | As member of `ex42::ExampleWithNamespace` | +| `ex42::ExampleWithARelation` | type of `number` member | migration of `float` to `double` | Direcetly via `ex42::ExampleWithARelation` | diff --git a/tests/schema_evolution/datalayout_new.yaml b/tests/schema_evolution/datalayout_new.yaml index 7d55b6e91..e9938fd1c 100755 --- a/tests/schema_evolution/datalayout_new.yaml +++ b/tests/schema_evolution/datalayout_new.yaml @@ -150,7 +150,7 @@ datatypes : Description : "Type with namespace and namespaced relation" Author : "Joschka Lingemann" Members: - - float number // just a number + - double number // just a number OneToOneRelations : - ex42::ExampleWithNamespace ref // a ref in a namespace OneToManyRelations : diff --git a/tests/schema_evolution/read_new_data.h b/tests/schema_evolution/read_new_data.h index afe3c0d2d..cdc3abf46 100644 --- a/tests/schema_evolution/read_new_data.h +++ b/tests/schema_evolution/read_new_data.h @@ -2,6 +2,7 @@ #define PODIO_TESTS_SCHEMAEVOLUTION_READNEWDATA_H // NOLINT(llvm-header-guard): folder structure not suitable #include "datamodel/ExampleHitCollection.h" +#include "datamodel/ExampleWithARelationCollection.h" #include "datamodel/ExampleWithArrayComponentCollection.h" #include "datamodel/ExampleWithNamespaceCollection.h" @@ -52,6 +53,15 @@ int readExampleWithNamespace(const podio::Frame& event) { return 0; } +int readExampleWithARelation(const podio::Frame& event) { + const auto& coll = event.get("floatToDoubleMemberTest"); + auto elem = coll[0]; + + ASSERT_EQUAL(elem.number(), (double)3.14f, "Conversion from float to double member does not work as expected"); + + return 0; +} + template int read_new_data(const std::string& filename) { ReaderT reader{}; @@ -63,6 +73,7 @@ int read_new_data(const std::string& filename) { result += readSimpleStruct(event); result += readExampleHit(event); result += readExampleWithNamespace(event); + result += readExampleWithARelation(event); return result; } diff --git a/tests/schema_evolution/write_old_data.h b/tests/schema_evolution/write_old_data.h index 552b6a67c..7676ae34b 100644 --- a/tests/schema_evolution/write_old_data.h +++ b/tests/schema_evolution/write_old_data.h @@ -2,6 +2,7 @@ #define PODIO_TESTS_SCHEMAEVOLUTION_WRITEOLDDATA_H // NOLINT(llvm-header-guard): folder structure not suitable #include "datamodel/ExampleHitCollection.h" +#include "datamodel/ExampleWithARelationCollection.h" #include "datamodel/ExampleWithArrayComponentCollection.h" #include "datamodel/ExampleWithNamespaceCollection.h" @@ -41,12 +42,21 @@ auto writeExampleWithNamespace() { return coll; } +auto writeExamplewWithARelation() { + ex42::ExampleWithARelationCollection coll; + auto elem = coll.create(); + elem.number(3.14f); + + return coll; +} + podio::Frame createFrame() { podio::Frame event; event.put(writeSimpleStruct(), "simpleStructTest"); event.put(writeExampleHit(), "datatypeMemberAdditionTest"); event.put(writeExampleWithNamespace(), "componentMemberRenameTest"); + event.put(writeExamplewWithARelation(), "floatToDoubleMemberTest"); return event; }