42 #include <visp3/core/vpConfig.h>
43 #include <visp3/core/vpImagePoint.h>
45 #if defined(VISP_HAVE_CATCH2)
47 #include <catch_amalgamated.hpp>
49 #ifdef ENABLE_VISP_NAMESPACE
52 TEST_CASE(
"Test comparison operator",
"[operator]")
65 CHECK_FALSE(ip1 != ip2);
66 CHECK_FALSE(ip1 == ip3);
70 TEST_CASE(
"Test pixel belongs to segment",
"[operator]")
73 SECTION(
"Segment horizontal right")
76 auto j = start_pixel.get_j();
77 for (
auto curr_pixel = start_pixel; curr_pixel.inSegment(start_pixel, end_pixel);
78 curr_pixel = curr_pixel.nextInSegment(start_pixel, end_pixel), j++) {
79 CHECK(curr_pixel ==
vpImagePoint(start_pixel.get_i(), j));
80 if (curr_pixel == end_pixel)
84 SECTION(
"Segment horizontal left")
87 auto j = start_pixel.get_j();
88 for (
auto curr_pixel = start_pixel; curr_pixel.inSegment(start_pixel, end_pixel);
89 curr_pixel = curr_pixel.nextInSegment(start_pixel, end_pixel), j--) {
90 CHECK(curr_pixel ==
vpImagePoint(start_pixel.get_i(), j));
91 if (curr_pixel == end_pixel)
95 SECTION(
"Segment vertical bottom")
98 auto i = start_pixel.get_i();
99 for (
auto curr_pixel = start_pixel; curr_pixel.inSegment(start_pixel, end_pixel);
100 curr_pixel = curr_pixel.nextInSegment(start_pixel, end_pixel), i++) {
101 CHECK(curr_pixel ==
vpImagePoint(i, start_pixel.get_j()));
102 if (curr_pixel == end_pixel)
106 SECTION(
"Segment vertical top")
109 auto i = start_pixel.get_i();
110 for (
auto curr_pixel = start_pixel; curr_pixel.inSegment(start_pixel, end_pixel);
111 curr_pixel = curr_pixel.nextInSegment(start_pixel, end_pixel), i--) {
112 CHECK(curr_pixel ==
vpImagePoint(i, start_pixel.get_j()));
113 if (curr_pixel == end_pixel)
119 int main(
int argc,
char *argv[])
121 Catch::Session session;
122 session.applyCommandLine(argc, argv);
123 int numFailed = session.run();
124 std::cout << (numFailed ?
"Test failed" :
"Test succeed") << std::endl;
142 std::cout <<
"We define ip1 with coordinates: " << ip1 << std::endl;
144 std::cout <<
"We define ip2 with coordinates: " << ip2 << std::endl;
146 std::cout <<
"We define ip3 with coordinates: " << ip3 << std::endl;
149 std::cout <<
"ip1 == ip2" << std::endl;
152 std::cout <<
"ip1 != ip2 (bad result)" << std::endl;
157 std::cout <<
"ip1 != ip2 (bad result)" << std::endl;
161 std::cout <<
"ip1 == ip2" << std::endl;
165 std::cout <<
"ip1 == ip3 (bad result)" << std::endl;
169 std::cout <<
"ip1 != ip3" << std::endl;
173 std::cout <<
"ip1 != ip3" << std::endl;
176 std::cout <<
"ip1 == ip3 (bad result)" << std::endl;
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...