Skip to content

Commit

Permalink
Fix test with catch
Browse files Browse the repository at this point in the history
  • Loading branch information
fspindle committed Oct 2, 2024
1 parent 69b2b43 commit 8805ce5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 43 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@
"source_location": "cpp",
"stdfloat": "cpp",
"text_encoding": "cpp",
"print": "cpp"
"print": "cpp",
"geometry": "cpp"
},
"C_Cpp.vcFormat.indent.namespaceContents": false,
"editor.formatOnSave": true,
Expand Down
44 changes: 2 additions & 42 deletions modules/core/test/tools/geometry/catchPolygon2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
using namespace VISP_NAMESPACE_NAME;
#endif

#ifdef VISP_HAVE_OPENCV
TEST_CASE("Check OpenCV-bsed convex hull")
TEST_CASE("Check polygon construction")
{
SECTION("From vpRect")
{
Expand All @@ -72,9 +71,8 @@ TEST_CASE("Check OpenCV-bsed convex hull")
REQUIRE(std::find(begin(rect_corners), end(rect_corners), poly_corner) != end(rect_corners));
}
#endif
}
}
}
#endif

int main(int argc, char *argv[])
{
Expand All @@ -85,47 +83,9 @@ int main(int argc, char *argv[])
}

#else
// Fallback to classic tests

bool testConvexHull()
{
#ifdef VISP_HAVE_OPENCV
const vpRect rect(0, 0, 200, 400);
std::vector<vpImagePoint> rect_corners;
rect_corners.push_back(rect.getTopLeft());
rect_corners.push_back(rect.getTopRight());
rect_corners.push_back(rect.getBottomRight());
rect_corners.push_back(rect.getBottomLeft());

vpPolygon poly;
poly.build(rect_corners, true);

// Check if std:c++14 or higher
#if ((__cplusplus >= 201402L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)))
for (const auto &poly_corner : poly.getCorners()) {
if (std::find(cbegin(rect_corners), cend(rect_corners), poly_corner) == cend(rect_corners)) {
return false;
}
}
#else
for (const auto &poly_corner : poly.getCorners()) {
if (std::find(begin(rect_corners), end(rect_corners), poly_corner) == end(rect_corners)) {
return false;
}
}
#endif

#endif

return true;
}

int main()
{
if (!testConvexHull()) {
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
}
#endif

0 comments on commit 8805ce5

Please sign in to comment.