-
Notifications
You must be signed in to change notification settings - Fork 46
Split up unit tests #413
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
Split up unit tests #413
Conversation
…to be working for neohookean
…s has been moved to separate new files
…t to automatically find all .cpp files under unitTests/, add README.md explaining unit tests
Co-authored-by: Copilot <[email protected]>
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.
Pull Request Overview
This PR reorganizes the existing monolithic unit test into per-material-model files with shared test utilities, and updates the build to auto-discover new tests.
- Extracted common mocks and helpers into
tests/unitTests/test_common.h - Refactored
test_material_common.hto include shared helpers and made utility functionsinline - Split
unitTests/test.cppinto multipletest_material_<model>.h/.cpppairs undermaterial_model_tests/
Reviewed Changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unitTests/test_common.h | New common mocks and base TestBase class for all tests |
| tests/unitTests/material_model_tests/test_material_common.h | Refactored common test helpers, moved implementations inline |
| tests/unitTests/material_model_tests/test_material_simo_taylor_91_volumetric_penalty.h | New header for Simo-Taylor91 volumetric penalty model tests |
| tests/unitTests/material_model_tests/test_material_simo_taylor_91_volumetric_penalty.cpp | New test fixture and cases for ST91 volumetric penalty |
| tests/unitTests/material_model_tests/test_material_quadratic_volumetric_penalty.h | New header for quadratic volumetric penalty model tests |
| tests/unitTests/material_model_tests/test_material_quadratic_volumetric_penalty.cpp | New test fixture and cases for quadratic volumetric penalty |
| tests/unitTests/material_model_tests/test_material_neohookean.h | New header for Neo-Hookean model tests |
| tests/unitTests/material_model_tests/test_material_neohookean.cpp | New Neo-Hookean test fixture and cases |
| tests/unitTests/material_model_tests/test_material_mooney_rivlin.h | New header for Mooney-Rivlin model tests |
| tests/unitTests/material_model_tests/test_material_mooney_rivlin.cpp | New Mooney-Rivlin test fixture and cases |
| tests/unitTests/material_model_tests/test_material_miehe_94_volumetric_penalty.h | New header for Miehe94 volumetric penalty model tests |
| tests/unitTests/material_model_tests/test_material_miehe_94_volumetric_penalty.cpp | New Miehe94 test fixture and cases |
| tests/unitTests/material_model_tests/test_material_holzapfel_ogden_MA.h | New header for Holzapfel-Ogden MA model tests |
| tests/unitTests/material_model_tests/test_material_holzapfel_ogden_MA.cpp | New Holzapfel-Ogden MA test fixture and cases |
| tests/unitTests/material_model_tests/test_material_holzapfel_ogden.h | New header for Holzapfel-Ogden model tests |
| tests/unitTests/material_model_tests/test_material_holzapfel_ogden.cpp | New Holzapfel-Ogden test fixture and cases |
Comments suppressed due to low confidence (4)
tests/unitTests/test_common.h:54
- [nitpick] The class name 'MockdmnType' mixes casing; for consistency, consider renaming to 'MockDmnType' following CamelCase conventions.
class MockdmnType : public dmnType {
tests/unitTests/material_model_tests/test_material_common.h:1793
- The signature of convertToArray passes both parameters by value and returns void, yet includes a return statement. It should be changed to void convertToArray(const Array3x3 &stdArray, Array &F), remove the return, and write directly into F.
void convertToArray(Array3x3 stdArray, Array<double> F) {
tests/unitTests/material_model_tests/test_material_common.h:1777
- convertToStdArray uses assert() but the file does not include . Please add #include to ensure assert is declared.
Array3x3 convertToStdArray(const Array<double> &F) {
tests/unitTests/material_model_tests/test_material_common.h:280
- computeLinearRegression uses std::accumulate but the header is not included. Please add #include at the top to avoid compilation errors.
inline std::pair<double, double> computeLinearRegression(const std::vector<double>& x, const std::vector<double>& y) {
tests/unitTests/material_model_tests/test_material_CANN_holzapfel_ogden.h
Show resolved
Hide resolved
tests/unitTests/material_model_tests/test_material_CANN_holzapfel_ogden.h
Outdated
Show resolved
Hide resolved
tests/unitTests/material_model_tests/test_material_CANN_holzapfel_ogden.h
Show resolved
Hide resolved
tests/unitTests/material_model_tests/test_material_CANN_holzapfel_ogden.h
Show resolved
Hide resolved
tests/unitTests/material_model_tests/test_material_CANN_holzapfel_ogden.h
Outdated
Show resolved
Hide resolved
tests/unitTests/material_model_tests/test_material_CANN_neohookean.cpp
Outdated
Show resolved
Hide resolved
tests/unitTests/material_model_tests/test_material_CANN_neohookean.cpp
Outdated
Show resolved
Hide resolved
tests/unitTests/material_model_tests/test_material_CANN_neohookean.cpp
Outdated
Show resolved
Hide resolved
tests/unitTests/material_model_tests/test_material_CANN_neohookean.cpp
Outdated
Show resolved
Hide resolved
tests/unitTests/material_model_tests/test_material_holzapfel_ogden_MA.cpp
Show resolved
Hide resolved
tests/unitTests/material_model_tests/test_material_holzapfel_ogden_MA.cpp
Show resolved
Hide resolved
tests/unitTests/material_model_tests/test_material_holzapfel_ogden_MA.cpp
Outdated
Show resolved
Hide resolved
tests/unitTests/material_model_tests/test_material_holzapfel_ogden_MA.cpp
Outdated
Show resolved
Hide resolved
tests/unitTests/material_model_tests/test_material_holzapfel_ogden_MA.cpp
Outdated
Show resolved
Hide resolved
tests/unitTests/material_model_tests/test_material_holzapfel_ogden_MA.cpp
Show resolved
Hide resolved
tests/unitTests/material_model_tests/test_material_holzapfel_ogden_MA.cpp
Show resolved
Hide resolved
ktbolt
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.
@aabrown100-git Very good work !
|
@aabrown100-git A few general comments about the unit tests.
|
|
@aabrown100-git Don't worry about making changes for you've spent a good amount of time on this and have done a great job ! |
…al tests to use Vector class for improved clarity and performance. Refactor convertToArray() to use const reference. Per comment by @ktbolt
…of std:Arrays, avoiding conversion between the two. Also, adjusted the tolerances on some tests to get them to pass. Also, use const references when accessing elements of F_small_list, for example
|
Thanks @ktbolt. I've addressed most of your comments, will continue this weekend. |
…pass on ubuntu Github machine
…ious material model test files for cleaner code.
|
@ktbolt I think I've addressed all your comments. Let me know if there's anything else I should change! |
ktbolt
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.
Looks good !
Current situation
Resolves #338
Release Notes
unitTests/test.handunitTests/test.cppinto separate files. These contained tests for different material models. I create separatetest_material_xxx.handtest_material_xxx.cppfiles for each material model.material_model_testsREADME.mddescribing unit testsCMakeLists.txtto automatically find all*.cppfiles underunitTests/and compile and run them when unit testing is performed.Documentation
README.mdprovides documentation for unit testingTesting
test.cppwere copied into the newtest_material_xxx.cppfiles.Code of Conduct & Contributing Guidelines