-
-
Notifications
You must be signed in to change notification settings - Fork 668
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
COMP: Add coverage IsCongruentImageGeometry IsSameImageGeometryAs #4592
COMP: Add coverage IsCongruentImageGeometry IsSameImageGeometryAs #4592
Conversation
// Test that a const pointer can be instantiated from a non-const pointer | ||
Image::ConstPointer myconstptr = image; | ||
if (!image->IsCongruentImageGeometry(myconstptr, 0.0, 0.0)) | ||
{ | ||
std::cerr << "Image compare to self fails IsCongruentImageGeometry" << std::endl; | ||
} | ||
if (!image->IsSameImageGeometryAs(myconstptr, 0.0, 0.0)) | ||
{ | ||
std::cerr << "Image compare to self fails IsSameImageGeometryAs" << std::endl; | ||
} | ||
|
||
return (EXIT_SUCCESS); |
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.
Technically, your test does not fail when IsCongruentImageGeometry returns false! It reaches return (EXIT_SUCCESS)
anyway.
Please 🙏 consider using GoogleTest for tests like this. With GTest, it would just be:
EXPECT_TRUE(image->IsSameImageGeometryAs(myconstptr, 0.0, 0.0));
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.
I just added these methods for SimpleITK and took full advantage of things for testing:
https://github.com/SimpleITK/SimpleITK/pull/2097/files#diff-b59e3fb36168b499154d941782889660f04ab0c66ed5a31f4a994ca88764b17d
@hjmjohnson I'llI see what I can do in the itkImageGTest.cxx file.
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.
ITK_TEST_EXPECT_TRUE
can do the job.
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.
@jhlegarreta I agree, if you want to keep using the old ITK test framework (instead of GoogleTest), you can do something like:
ITK_TEST_EXPECT_TRUE(image->IsSameImageGeometryAs(myconstptr, 0.0, 0.0));
FYI, there's a small difference between ITK_TEST_EXPECT_TRUE
and GTest EXPECT_TRUE
: ITK_TEST_EXPECT_TRUE
will exit the test immediately if it fails, whereas with a GTest EXPECT_TRUE
failure, the unit test will not exit immediately. (Even though it will be reported as a test failure, by GTest.)
Superceeded by @blowekamp #4594 |
PR Checklist