From d18ddae4cf4adcee93159845adbb26a617e97b9b Mon Sep 17 00:00:00 2001 From: Luc Grosheintz Date: Wed, 23 Aug 2023 14:24:23 +0200 Subject: [PATCH] Review comments. --- test/unit_tests/container/generic_data_handle.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/unit_tests/container/generic_data_handle.cpp b/test/unit_tests/container/generic_data_handle.cpp index b38a62260f..f9bc4c3ebc 100644 --- a/test/unit_tests/container/generic_data_handle.cpp +++ b/test/unit_tests/container/generic_data_handle.cpp @@ -60,12 +60,12 @@ TEST_CASE("POINTER data_handle") { auto& container = model.node_data(); // These two object create a row each and keep it alive. - auto row1_owner = Node::owning_handle{container}; - auto row2_owner = Node::owning_handle{container}; + auto row1_owner = std::make_unique(container); + auto row2_owner = std::make_unique(container); // We'd like a data_handle to the both voltages. - auto v1 = container.get_handle(row1_owner.id(), 0); - auto v2 = container.get_handle(row2_owner.id(), 0); + auto v1 = container.get_handle(row1_owner->id(), 0); + auto v2 = container.get_handle(row2_owner->id(), 0); // Initialize with the wrong sign. *v1 = -1.0; @@ -84,7 +84,7 @@ TEST_CASE("POINTER data_handle") { // We set up everything such that the `soa` containers have two voltages. // We'll now study what happens to a Datum that refers to one of these. In // generated code this datum is called `_ppval[0]`. The - Datum* _ppval = (Datum*) malloc(sizeof(Datum)); + auto _ppval = std::vector(1); // Important: `v1_ptr` has type `double *`. Here, it's just // a pointer. The "promotion" to data_handle happens inside @@ -115,5 +115,8 @@ TEST_CASE("POINTER data_handle") { // This is still a compiler error: // _ppval[0].get() = nullptr; - free(_ppval); + // What happens when the rows are freed? + row1_owner = nullptr; + row2_owner = nullptr; + REQUIRE(_ppval[0].get() == nullptr); }