Skip to content

Extract check_input from process_image for focused unit tests - #309

Merged
antond-weta merged 4 commits into
AcademySoftwareFoundation:mainfrom
La1itchauhan:issue-274-check-input
Aug 2, 2026
Merged

Extract check_input from process_image for focused unit tests#309
antond-weta merged 4 commits into
AcademySoftwareFoundation:mainfrom
La1itchauhan:issue-274-check-input

Conversation

@La1itchauhan

Copy link
Copy Markdown
Contributor

Description

This PR extracts the early input validation logic from
ImageConverter::process_image() into a dedicated
ImageConverter::check_input() function.

The validation logic and observable behaviour remain unchanged. This
refactor allows the validation path to be exercised directly in unit
tests without relying on the full image processing pipeline.

Closes #274.

Tests

Added direct unit tests for check_input() covering:

  • Empty input filename
  • Non-existent input file

The existing process_image() validation tests were retained to ensure
the public behaviour remains unchanged.

Checklist:

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable. (No documentation update required for this refactor.)
  • I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).
  • My code follows the prevailing code style of this project. If I haven't already run clang-format before submitting, I definitely will look at the CI test that runs clang-format and fix anything that it highlights as being nonconforming.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 27, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: La1itchauhan / name: La1itchauhan (4bdb9d4)

@La1itchauhan
La1itchauhan force-pushed the issue-274-check-input branch from b58c6b1 to 4bdb9d4 Compare July 27, 2026 15:19
@codecov-commenter

codecov-commenter commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.90%. Comparing base (7e4223a) to head (33adac6).

Files with missing lines Patch % Lines
src/rawtoaces_util/image_converter.cpp 81.81% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #309   +/-   ##
=======================================
  Coverage   91.89%   91.90%           
=======================================
  Files          17       17           
  Lines        3777     3781    +4     
  Branches      558      559    +1     
=======================================
+ Hits         3471     3475    +4     
  Misses        306      306           
Files with missing lines Coverage Δ
src/rawtoaces_util/image_converter.cpp 79.62% <81.81%> (+0.05%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7e4223a...33adac6. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@antond-weta

Copy link
Copy Markdown
Contributor

Hi @La1itchauhan, thanks for doing this! Looking good, just raised a couple minor things.
Also please check the clang-format check issues above.
Thanks

@La1itchauhan
La1itchauhan force-pushed the issue-274-check-input branch from 255a167 to bb0809c Compare July 28, 2026 08:33

@antond-weta antond-weta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, forgot to submit the review

Comment thread src/rawtoaces_util/image_converter.cpp Outdated
}

bool ImageConverter::process_image( const std::string &input_filename )
bool ImageConverter::check_input( const std::string &input_filename )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would suggest making this a free function for now, not a method of ImageConverter. It doesn't need to be a part of the public interface. Please remove the declaration from the header. If you need the function exposed somewhere for unit testing, declare it in rawtoaces_util_priv.h instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated — check_input is now a free function declared in rawtoaces_util_priv.h (following the same pattern as fetch_missing_metadata). process_image now passes its own status and last_error_message through by reference, so its external behavior remains unchanged.

Comment thread tests/test_image_converter.cpp Outdated
std::string::npos,
true );
}
void test_check_input_empty_filename()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That functionality has already been covered with unit tests. If you'd like to make changes to unit tests to better reflect the code layout, you may want to edit the existing tests instead of adding new ones.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed the duplicate test functions as you suggested to better reflect the code layout and instead updated the existing test_last_error_message_empty_filename and test_last_error_message_file_not_found tests to call check_input directly. My thinking was that this better addresses #274 by testing the validation logic independently, without introducing additional test cases. If you'd prefer those tests to remain focused on process_image and keep this change more minimal, happy to adjust.

@antond-weta

Copy link
Copy Markdown
Contributor

Looks good! Please address the clang-format issues and I'll get this merged in. Thanks!

Signed-off-by: La1itchauhan <chauhanlalitofficial@gmail.com>
Signed-off-by: La1itchauhan <chauhanlalitofficial@gmail.com>
Signed-off-by: La1itchauhan <chauhanlalitofficial@gmail.com>
@antond-weta
antond-weta force-pushed the issue-274-check-input branch from 1bbe34b to f45f807 Compare August 2, 2026 06:10
Signed-off-by: La1itchauhan <chauhanlalitofficial@gmail.com>
@antond-weta
antond-weta merged commit 8b752e1 into AcademySoftwareFoundation:main Aug 2, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ImageConverter] Extract check_input from process_image for focused unit tests

3 participants