Commit 71587406 authored by Baptiste Esteban's avatar Baptiste Esteban
Browse files

Finish tests

parent 7c3d217e
Pipeline #30212 failed with stages
in 21 minutes and 33 seconds
...@@ -67,7 +67,6 @@ windows-debug: ...@@ -67,7 +67,6 @@ windows-debug:
stage: build stage: build
script: script:
- mkdir build && cd build - mkdir build && cd build
- conan remote list
- conan install .. --build missing -s compiler.cppstd=20 -e CXXFLAGS="" -e CCFLAGS="" -pr $CONAN_PROFILE -o pylene:fPIC=True - conan install .. --build missing -s compiler.cppstd=20 -e CXXFLAGS="" -e CCFLAGS="" -pr $CONAN_PROFILE -o pylene:fPIC=True
- cmake -G Ninja .. -DCMAKE_BUILD_TYPE=$PYLENE_CONFIGURATION -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DPYLENE_BUILD_PYTHON=ON - cmake -G Ninja .. -DCMAKE_BUILD_TYPE=$PYLENE_CONFIGURATION -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DPYLENE_BUILD_PYTHON=ON
- cmake --build . --target Pylene-core - cmake --build . --target Pylene-core
......
...@@ -21,7 +21,7 @@ TEST(IO, cfitsio_not_an_image) ...@@ -21,7 +21,7 @@ TEST(IO, cfitsio_not_an_image)
catch (std::runtime_error& e) 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_EQ(std::strcmp("Unhandled image number of dimension (Got 0, expected in [1 - 4])", e.what()), 0);
} }
ASSERT_TRUE(has_raised); ASSERT_TRUE(has_raised);
} }
...@@ -37,10 +37,10 @@ TEST(IO, cfitsio_2D_uint8) ...@@ -37,10 +37,10 @@ TEST(IO, cfitsio_2D_uint8)
}; };
auto img = mln::io::fits::imread(filename, 1); auto img = mln::io::fits::imread(filename, 1);
ASSERT_TRUE(img.sample_type() == mln::sample_type_id::UINT8); ASSERT_EQ(img.sample_type(), mln::sample_type_id::UINT8);
ASSERT_TRUE(img.pdim() == 2); ASSERT_EQ(img.pdim(), 2);
ASSERT_TRUE(img.width() == 5); ASSERT_EQ(img.width(), 5);
ASSERT_TRUE(img.height() == 5); ASSERT_EQ(img.height(), 5);
auto* casted = img.cast_to<std::uint8_t, 2>(); auto* casted = img.cast_to<std::uint8_t, 2>();
ASSERT_IMAGES_EQ_EXP(*casted, ref); ASSERT_IMAGES_EQ_EXP(*casted, ref);
...@@ -57,10 +57,10 @@ TEST(IO, cfitsio_2D_int16) ...@@ -57,10 +57,10 @@ TEST(IO, cfitsio_2D_int16)
}; };
auto img = mln::io::fits::imread(filename, 2); auto img = mln::io::fits::imread(filename, 2);
ASSERT_TRUE(img.sample_type() == mln::sample_type_id::INT16); ASSERT_EQ(img.sample_type(), mln::sample_type_id::INT16);
ASSERT_TRUE(img.pdim() == 2); ASSERT_EQ(img.pdim(), 2);
ASSERT_TRUE(img.width() == 5); ASSERT_EQ(img.width(), 5);
ASSERT_TRUE(img.height() == 5); ASSERT_EQ(img.height(), 5);
auto* casted = img.cast_to<std::int16_t, 2>(); auto* casted = img.cast_to<std::int16_t, 2>();
ASSERT_IMAGES_EQ_EXP(*casted, ref); ASSERT_IMAGES_EQ_EXP(*casted, ref);
...@@ -77,10 +77,10 @@ TEST(IO, cfitsio_2D_int32) ...@@ -77,10 +77,10 @@ TEST(IO, cfitsio_2D_int32)
}; };
auto img = mln::io::fits::imread(filename, 3); auto img = mln::io::fits::imread(filename, 3);
ASSERT_TRUE(img.sample_type() == mln::sample_type_id::INT32); ASSERT_EQ(img.sample_type(), mln::sample_type_id::INT32);
ASSERT_TRUE(img.pdim() == 2); ASSERT_EQ(img.pdim(), 2);
ASSERT_TRUE(img.width() == 5); ASSERT_EQ(img.width(), 5);
ASSERT_TRUE(img.height() == 5); ASSERT_EQ(img.height(), 5);
auto* casted = img.cast_to<std::int32_t, 2>(); auto* casted = img.cast_to<std::int32_t, 2>();
ASSERT_IMAGES_EQ_EXP(*casted, ref); ASSERT_IMAGES_EQ_EXP(*casted, ref);
...@@ -97,10 +97,10 @@ TEST(IO, cfitsio_2D_int64) ...@@ -97,10 +97,10 @@ TEST(IO, cfitsio_2D_int64)
}; };
auto img = mln::io::fits::imread(filename, 4); auto img = mln::io::fits::imread(filename, 4);
ASSERT_TRUE(img.sample_type() == mln::sample_type_id::INT64); ASSERT_EQ(img.sample_type(), mln::sample_type_id::INT64);
ASSERT_TRUE(img.pdim() == 2); ASSERT_EQ(img.pdim(), 2);
ASSERT_TRUE(img.width() == 5); ASSERT_EQ(img.width(), 5);
ASSERT_TRUE(img.height() == 5); ASSERT_EQ(img.height(), 5);
auto* casted = img.cast_to<std::int64_t, 2>(); auto* casted = img.cast_to<std::int64_t, 2>();
ASSERT_IMAGES_EQ_EXP(*casted, ref); ASSERT_IMAGES_EQ_EXP(*casted, ref);
...@@ -117,10 +117,10 @@ TEST(IO, cfitsio_2D_float) ...@@ -117,10 +117,10 @@ TEST(IO, cfitsio_2D_float)
}; };
auto img = mln::io::fits::imread(filename, 5); auto img = mln::io::fits::imread(filename, 5);
ASSERT_TRUE(img.sample_type() == mln::sample_type_id::FLOAT); ASSERT_EQ(img.sample_type(), mln::sample_type_id::FLOAT);
ASSERT_TRUE(img.pdim() == 2); ASSERT_EQ(img.pdim(), 2);
ASSERT_TRUE(img.width() == 5); ASSERT_EQ(img.width(), 5);
ASSERT_TRUE(img.height() == 5); ASSERT_EQ(img.height(), 5);
auto* casted = img.cast_to<float, 2>(); auto* casted = img.cast_to<float, 2>();
ASSERT_IMAGES_EQ_EXP(*casted, ref); ASSERT_IMAGES_EQ_EXP(*casted, ref);
...@@ -137,11 +137,44 @@ TEST(IO, cfitsio_2D_double) ...@@ -137,11 +137,44 @@ TEST(IO, cfitsio_2D_double)
}; };
auto img = mln::io::fits::imread(filename, 6); auto img = mln::io::fits::imread(filename, 6);
ASSERT_TRUE(img.sample_type() == mln::sample_type_id::DOUBLE); ASSERT_EQ(img.sample_type(), mln::sample_type_id::DOUBLE);
ASSERT_TRUE(img.pdim() == 2); ASSERT_EQ(img.pdim(), 2);
ASSERT_TRUE(img.width() == 5); ASSERT_EQ(img.width(), 5);
ASSERT_TRUE(img.height() == 5); ASSERT_EQ(img.height(), 5);
auto* casted = img.cast_to<double, 2>(); auto* casted = img.cast_to<double, 2>();
ASSERT_IMAGES_EQ_EXP(*casted, ref); ASSERT_IMAGES_EQ_EXP(*casted, ref);
}
TEST(IO, cfitsio_3D)
{
auto img = mln::io::fits::imread(filename, 7);
ASSERT_EQ(img.sample_type(), mln::sample_type_id::UINT8);
ASSERT_EQ(img.pdim(), 3);
ASSERT_EQ(img.width(), 5);
ASSERT_EQ(img.height(), 4);
auto* casted = img.cast_to<std::uint8_t, 3>();
int cur = 0;
mln_foreach (auto p, casted->domain())
ASSERT_EQ(casted->operator()(p), cur++);
}
TEST(IO, cfitsio_read_to_argument)
{
mln::image2d<std::uint8_t> ref = {
{0, 1, 2, 3, 4}, //
{5, 6, 7, 8, 9}, //
{10, 11, 12, 13, 14}, //
{15, 16, 17, 18, 19}, //
{20, 21, 22, 23, 24} //
};
mln::image2d<std::uint8_t> img;
mln::io::fits::imread(filename, img, 1);
ASSERT_EQ(img.width(), 5);
ASSERT_EQ(img.height(), 5);
ASSERT_IMAGES_EQ_EXP(img, ref);
} }
\ No newline at end of file
Markdown is supported
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