-
Notifications
You must be signed in to change notification settings - Fork 11
ENH: Add unit test functions for comparing full datastructure #1500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
ENH: Add unit test functions for comparing full datastructure #1500
Conversation
0fd375f to
2c687c1
Compare
2c687c1 to
2db7460
Compare
2db7460 to
c02c3c8
Compare
JDuffeyBQ
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably also check objects like geometries and attribute matrices for equality as well.
| #include <catch2/catch.hpp> | ||
|
|
||
| #include "simplnx/Core/Application.hpp" | ||
| #include "simplnx/DataStructure/IO/HDF5/DataStructureWriter.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were these includes missing before? And same for other files.
| // groupACDPath.createChildPath(arrayI->getName()); | ||
| // groupBCDPath.createChildPath(arrayI->getName()); | ||
| // | ||
| // groupBCDPath.createChildPath(arrayJ->getName()); | ||
| // groupACEPath.createChildPath(arrayJ->getName()); | ||
| // groupBCEPath.createChildPath(arrayJ->getName()); | ||
| // groupBEPath.createChildPath(arrayJ->getName()); | ||
| // groupBFEPath.createChildPath(arrayJ->getName()); | ||
| // | ||
| // groupACEPath.createChildPath(arrayK->getName()); | ||
| // groupBCEPath.createChildPath(arrayK->getName()); | ||
| // groupBEPath.createChildPath(arrayK->getName()); | ||
| // groupBFEPath.createChildPath(arrayK->getName()); | ||
| // | ||
| // groupBFGPath.createChildPath(arrayL->getName()); | ||
| // | ||
| // groupBFGPath.createChildPath(arrayM->getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were these used?
| if(parentA == nullptr || parentB == nullptr) | ||
| { | ||
| // std::cout << "DEBUG TEST: parentA or parentB is null!"; | ||
| INFO("DEBUG TEST: parentA or parentB is null!"); | ||
| REQUIRE(false); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if(parentA == nullptr || parentB == nullptr) | |
| { | |
| // std::cout << "DEBUG TEST: parentA or parentB is null!"; | |
| INFO("DEBUG TEST: parentA or parentB is null!"); | |
| REQUIRE(false); | |
| } | |
| REQUIRE(parentA != nullptr); | |
| REQUIRE(parentB != nullptr); |
| childrenNamesB = parentB->getDataMap().getNames(); | ||
| } | ||
|
|
||
| for(int i = 0; i < childrenNamesA.size(); ++i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| for(int i = 0; i < childrenNamesA.size(); ++i) | |
| for(usize i = 0; i < childrenNamesA.size(); ++i) |
| auto objectA = dataStructureA.getData(childPath); | ||
| auto objectB = dataStructureB.getData(childPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| auto objectA = dataStructureA.getData(childPath); | |
| auto objectB = dataStructureB.getData(childPath); | |
| const DataObject* objectA = dataStructureA.getData(childPath); | |
| const DataObject* objectB = dataStructureB.getData(childPath); | |
| REQUIRE(objectA != nullptr); | |
| REQUIRE(objectB != nullptr); |
| REQUIRE(dataArrayA != nullptr); | ||
| REQUIRE(dataArrayB != nullptr); | ||
| CompareStringArrays(*dataArrayA, *dataArrayB); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| REQUIRE(dataArrayA != nullptr); | |
| REQUIRE(dataArrayB != nullptr); | |
| CompareStringArrays(*dataArrayA, *dataArrayB); | |
| REQUIRE(stringArrayA != nullptr); | |
| REQUIRE(stringArrayB != nullptr); | |
| CompareStringArrays(*stringArrayA, *stringArrayB); |
| // Make sure both are the same object type | ||
| // If this fails the test will throw and return at this point |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Make sure both are the same object type | |
| // If this fails the test will throw and return at this point |
| } catch(std::exception& e) | ||
| { | ||
| REQUIRE(false); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } catch(std::exception& e) | |
| { | |
| REQUIRE(false); | |
| } | |
| } catch(const std::exception& e) | |
| { | |
| INFO(fmt::format("Caught exception: {}", e.what())); | |
| REQUIRE(false); | |
| } |
Is there a particular exception we are expecting to catch?
| default: | ||
| std::cout << "Missing DataType: " << static_cast<uint32>(objectA->getDataObjectType()) << std::endl; | ||
| INFO(fmt::format("DEBUG TEST: Child path ({}) cannot be found or has different array types in data structures A and B!", childPath.toString())); | ||
| REQUIRE(false); | ||
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| default: | |
| std::cout << "Missing DataType: " << static_cast<uint32>(objectA->getDataObjectType()) << std::endl; | |
| INFO(fmt::format("DEBUG TEST: Child path ({}) cannot be found or has different array types in data structures A and B!", childPath.toString())); | |
| REQUIRE(false); | |
| break; | |
| default: { | |
| auto underlyingDataType = to_underlying(objectA->getDataObjectType()); | |
| std::cout << "Missing DataType: " << underlyingDataType << std::endl; | |
| INFO(fmt::format("Object at path ({}) has unhandled type ({})", childPath.toString(), underlyingDataType)); | |
| REQUIRE(false); | |
| break; | |
| } |
Also might as well store the data object type before this point since we use it before the switch.
| DataPath childPath = parentGroup.createChildPath(childrenNamesA[i]); | ||
| if(dataStructureA.getDataAs<BaseGroup>(childPath)) | ||
| { | ||
| CompareDataStructures(dataStructureA, dataStructureB, childPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is recursive, it is possible a very deep DataStructure would theoretically be an issue.
No description provided.