diff --git a/src/ifcparse/parse.cpp b/src/ifcparse/parse.cpp index 5fb2ad7acb..680a0e0045 100644 --- a/src/ifcparse/parse.cpp +++ b/src/ifcparse/parse.cpp @@ -2362,7 +2362,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con if (it == byid_.end()) { logger_.get().error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset)); } else { - auto& storage = owner; + auto storage = owner; auto attr_index = p.first.index_; if (storage->template has_attribute_value(attr_index)) { @@ -2406,7 +2406,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con } } - auto& storage = owner; + auto storage = owner; auto attr_index = p.first.index_; if (storage->template has_attribute_value(attr_index)) { @@ -2448,7 +2448,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con } } - auto& storage = owner; + auto storage = owner; auto attr_index = p.first.index_; if (storage->template has_attribute_value(attr_index)) { diff --git a/src/ifcparse/tests/CMakeLists.txt b/src/ifcparse/tests/CMakeLists.txt index 8275fd27ab..3e1fda0251 100644 --- a/src/ifcparse/tests/CMakeLists.txt +++ b/src/ifcparse/tests/CMakeLists.txt @@ -3,9 +3,15 @@ add_executable(test_ifcopenshell_parse test_ifcopenshell_parse.cpp ) -target_link_libraries(test_ifcopenshell_parse PRIVATE Catch2::Catch2WithMain) +target_compile_definitions(test_ifcopenshell_parse PRIVATE + IFCOPENSHELL_TEST_FIXTURES="${CMAKE_CURRENT_SOURCE_DIR}/../../ifcopenshell-python/test/fixtures" +) +target_link_libraries(test_ifcopenshell_parse PRIVATE Catch2::Catch2WithMain IfcParse) +add_dependencies(test_ifcopenshell_parse parse_schema_ifc4) catch_discover_tests(test_ifcopenshell_parse DL_PATHS $ $ + $ + $ ) diff --git a/src/ifcparse/tests/test_ifcopenshell_parse.cpp b/src/ifcparse/tests/test_ifcopenshell_parse.cpp index f65ab9e296..c15f9dc537 100644 --- a/src/ifcparse/tests/test_ifcopenshell_parse.cpp +++ b/src/ifcparse/tests/test_ifcopenshell_parse.cpp @@ -1,7 +1,27 @@ // This file was generated with the assistance of an AI coding tool. #include +#include +#include +#include -TEST_CASE("IfcParse C++ test scaffold is registered", "[ifcparse]") { - REQUIRE(true); +TEST_CASE("IfcPropertySetDefinitionSet references are resolved without replacing their owner", "[ifcparse]") { + const std::string fixture = std::string(IFCOPENSHELL_TEST_FIXTURES) + "/ColumnPSetsOfSets.ifc"; + ifcopenshell::file file(fixture); + + REQUIRE(file.good()); + + const auto relationship = file.instance_by_id(139); + REQUIRE(relationship); + CHECK(relationship.id() == 139); + CHECK(relationship.declaration().name() == "IfcRelDefinesByProperties"); + + const express::base definition_set = relationship.get_attribute_value(5); + REQUIRE(definition_set); + CHECK(definition_set.declaration().name() == "IfcPropertySetDefinitionSet"); + + const std::vector definitions = definition_set.get_attribute_value(0); + REQUIRE(definitions.size() == 2); + CHECK(definitions[0].id() == 136); + CHECK(definitions[1].id() == 138); }