Skip to content

Commit

Permalink
ENH: Add additional testing for zero sized label object
Browse files Browse the repository at this point in the history
  • Loading branch information
blowekamp authored and Leengit committed May 4, 2021
1 parent daa2a20 commit 1fba0db
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ class StatisticsLabelMapFixture : public ::testing::Test

std::sort(values.begin(), values.end());

assert(!values.empty());

auto n1 = values.size() / 2;
if (values.size() % 2 == 0)
{
Expand All @@ -170,6 +172,7 @@ TEST_F(StatisticsLabelMapFixture, 2D_zero)

Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(labelImage, image, 1, 1 << 8);

ASSERT_GT(labelObject->Size(), 0);
EXPECT_NEAR(0.0, labelObject->GetMinimum(), 1e-12);
EXPECT_NEAR(0.0, labelObject->GetMaximum(), 1e-12);
EXPECT_NEAR(Utils::ComputeExactMedian(labelObject, image), labelObject->GetMedian(), 1e-12);
Expand Down Expand Up @@ -205,6 +208,7 @@ TEST_F(StatisticsLabelMapFixture, 2D_ones_with_outliers)

Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(labelImage, image, label, 1 << 16);

ASSERT_GT(labelObject->Size(), 0);
EXPECT_NEAR(value, labelObject->GetMinimum(), 1e-12);
EXPECT_NEAR(value, labelObject->GetMaximum(), 1e-12);
EXPECT_NEAR(Utils::ComputeExactMedian(labelObject, image), labelObject->GetMedian(), 1e-12);
Expand Down Expand Up @@ -240,6 +244,7 @@ TEST_F(StatisticsLabelMapFixture, 2D_rand_with_outliers)

Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(labelImage, image, label, 1 << 16);

ASSERT_GT(labelObject->Size(), 0);
EXPECT_NEAR(0.0, labelObject->GetMinimum(), 1e-12);
EXPECT_NEAR(500.0, labelObject->GetMaximum(), 1e-12);
EXPECT_NEAR(Utils::ComputeExactMedian(labelObject, image), labelObject->GetMedian(), 1e-12);
Expand Down Expand Up @@ -273,6 +278,7 @@ TEST_F(StatisticsLabelMapFixture, 2D_even)

Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(labelImage, image, label, 1 << 8);

ASSERT_GT(labelObject->Size(), 0);
EXPECT_NEAR(1.0, labelObject->GetMinimum(), 1e-12);
EXPECT_NEAR(200.0, labelObject->GetMaximum(), 1e-12);
EXPECT_NEAR(Utils::ComputeExactMedian(labelObject, image), labelObject->GetMedian(), 1e-12);
Expand Down Expand Up @@ -307,6 +313,7 @@ TEST_F(StatisticsLabelMapFixture, 2D_three)

Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(labelImage, image, label, 1 << 8);

ASSERT_GT(labelObject->Size(), 0);
EXPECT_NEAR(1.0, labelObject->GetMinimum(), 1e-12);
EXPECT_NEAR(10.0, labelObject->GetMaximum(), 1e-12);
EXPECT_NEAR(Utils::ComputeExactMedian(labelObject, image), labelObject->GetMedian(), 1e-12);
Expand Down

0 comments on commit 1fba0db

Please sign in to comment.