Commit 812c82e8 authored by Baptiste Esteban's avatar Baptiste Esteban
Browse files

Check the exception raised

parent 9f59674c
Pipeline #30195 failed with stages
in 3 minutes and 1 second
...@@ -98,7 +98,7 @@ namespace mln::io::fits ...@@ -98,7 +98,7 @@ namespace mln::io::fits
int ndim; int ndim;
fits_get_img_dim(file, &ndim, &status); fits_get_img_dim(file, &ndim, &status);
if (ndim == 0 || ndim > 4) if (ndim == 0 || ndim > 4)
throw std::runtime_error(fmt::format("Unhandled image number of dimension (Got {}, expected in [1 - 4]", ndim)); throw std::runtime_error(fmt::format("Unhandled image number of dimension (Got {}, expected in [1 - 4])", ndim));
// Get the dimensions // Get the dimensions
long dims[4]; long dims[4];
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <cstring>
static const auto filename = fixtures::ImagePath::concat_with_filename("test.fit"); static const auto filename = fixtures::ImagePath::concat_with_filename("test.fit");
TEST(IO, cfitsio_not_an_image) TEST(IO, cfitsio_not_an_image)
...@@ -16,9 +18,10 @@ TEST(IO, cfitsio_not_an_image) ...@@ -16,9 +18,10 @@ TEST(IO, cfitsio_not_an_image)
auto img = mln::io::fits::imread(filename, 0); auto img = mln::io::fits::imread(filename, 0);
(void)img; (void)img;
} }
catch (std::runtime_error&) catch (std::runtime_error& e)
{ {
has_raised = true; has_raised = true;
ASSERT_TRUE(std::strcmp("Unhandled image number of dimension (Got 0, expected in [1 - 4])",e.what()) == 0);
} }
ASSERT_TRUE(has_raised); ASSERT_TRUE(has_raised);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment