Skip to content
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

Convert unit tests to googletest #200

Merged
merged 32 commits into from
Feb 26, 2024
Merged

Convert unit tests to googletest #200

merged 32 commits into from
Feb 26, 2024

Conversation

spahrenk
Copy link
Contributor

@spahrenk spahrenk commented Feb 5, 2024

Description

  • Converts all unit tests to use googletest within a separate project saved in test/unit_tests. These unit tests are run along with extant model tests via RUN_TESTS:Build.
  • The CMake script for HPWHsim was changed to use $(PROJECT_NAME) (currently set as HPWHsim) as the name of the compiled library, rather than libHPWHSim. The corresponding change was made in a cse branch add-unit-tests-hpwh.
  • The file testUtilityFcts.cc was removed entirely. Code within that file was either redundant, no longer needed, or changed to HPWH member functions. The function getHPWHObject was changed to an overloaded version of HPWH::initPreset using a string argument. Some function names were altered slightly for clarity.
  • The changes above highlighted the special case of HPWH model TamScalable_SP. The code allowed initiating variations of this model with double- and half-heating capacities, but these sub-models do not exist by model number, so ad hoc code had been inserted to perform the scaling after initialization via Preset. These were changed to regular models, with the scaling done in HPWH::initPreset. (Alternatively, model modifiers could be used to distinguish these, which seemed outside the scope of this PR.) The non-member function scaleVector was added to perform the scaling. These submodel numbers remain undefined in cse.
  • An additional constexpr was defined to convert between metric and imperial units for $r$ values.
  • All HPWH tests are passed in their new forms.
  • The companion cse branch passes all tests.

Author Progress Checklist:

  • Open draft pull request
    • Make title clearly understandable in a standalone change log context
    • Assign yourself the issue
    • Add at least one label (enhancement, bug, or maintenance)
    • Link the issue(s) addressed by this PR (under "Development" in the sidebar menu)
  • Make code changes (if you haven't already)
  • Self-review of code
    • My code follows the style guidelines of this project
    • I have added comments to my code, particularly in hard-to-understand areas
    • I have only committed the necessary changes for this fix or feature
    • I have made corresponding changes to the documentation
    • My changes generate no new warnings
    • I have ensured that my fix is effective or that my feature works as intended by:
      • exercising the code changes in the test framework, and/or
      • manually verifying the changes (as explained in the the pull request description above)
    • My changes pass all local tests
    • My changes successfully passes CI checks
    • Add any unit test for proof and documentation.
    • Merge in main branch and address resulting conflicts and/or test failures.
  • Move pull request out of draft mode and assign reviewers
  • [] Iterate with reviewers until all changes are approved
    • Make changes in response to reviewer comments
    • Merge in main branch and address resulting conflicts and/or test failures.
    • Re-request review in GitHub

Reviewer Checklist:

  • Read the pull request description
  • Perform a code review on GitHub
  • Confirm all CI checks pass and there are no build warnings
  • Pull, build, and run automated tests locally
  • Perform manual tests of the fix or feature locally
  • Add any review comments, if applicable
  • Submit review in GitHub as either
    • Request changes, or
    • Approve
  • Iterate with author until all changes are approved

@spahrenk spahrenk self-assigned this Feb 5, 2024
@nealkruis
Copy link
Member

@spahrenk this looks good to me. A lot of unrelated cleanup here too that should maybe be in a separate branch, but it's not worth the effort to separate it out now. The source file in the companion CSE branch been completely reformatted, making it impossible to see where the API has caused changes. This highlights the need to get clang formatting set up in CSE, but for now, can you change the branch with your "autoformat" turned off?

@spahrenk
Copy link
Contributor Author

Ah, OK. I'll clean that up.

@spahrenk spahrenk marked this pull request as ready for review February 12, 2024 18:35
@codecov-commenter
Copy link

codecov-commenter commented Feb 13, 2024

Codecov Report

Attention: Patch coverage is 85.66038% with 38 lines in your changes are missing coverage. Please review.

Project coverage is 66.78%. Comparing base (4609465) to head (10663ef).

Files Patch % Lines
src/HPWH.cc 85.34% 34 Missing ⚠️
src/HPWHpresets.cc 85.19% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #200      +/-   ##
==========================================
+ Coverage   66.08%   66.78%   +0.71%     
==========================================
  Files           6        6              
  Lines        4979     5157     +178     
==========================================
+ Hits         3290     3444     +154     
- Misses       1689     1713      +24     
Flag Coverage Δ
integration 66.78% <85.66%> (+0.71%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@spahrenk spahrenk requested a review from nealkruis February 26, 2024 16:05
CMakeLists.txt Outdated
@@ -46,7 +46,8 @@ add_subdirectory(vendor)
add_subdirectory(src)

if (${PROJECT_NAME}_BUILD_TESTING)
add_subdirectory(test)
add_subdirectory(test/unit_tests)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One very minor change here: This subdirectory should be added from the test/CMakeLists.txt.

@nealkruis nealkruis self-requested a review February 26, 2024 17:31
@nealkruis nealkruis merged commit f90302f into main Feb 26, 2024
8 checks passed
@nealkruis nealkruis deleted the add-unit-tests branch February 26, 2024 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants