38 #include <visp3/core/vpConfig.h>
39 #include <visp3/core/vpEndian.h>
41 #if defined(VISP_HAVE_EIGEN3) && defined(VISP_HAVE_CATCH2)
43 #include <catch_amalgamated.hpp>
45 #ifdef ENABLE_VISP_NAMESPACE
49 TEST_CASE(
"Test reinterpret_cast_uchar_to_uint16_LE",
"[vpEndian_test]")
51 unsigned char bitmap[] = { 100, 110, 120, 130 };
55 CHECK((val01 & 0x00FF) == bitmap[0]);
56 CHECK(((val01 & 0xFF00) >> 8) == bitmap[1]);
57 CHECK((val01 >> 8) == bitmap[1]);
59 CHECK((val12 & 0x00FF) == bitmap[2]);
60 CHECK(((val12 & 0xFF00) >> 8) == bitmap[3]);
61 CHECK((val12 >> 8) == bitmap[3]);
64 TEST_CASE(
"Test bitwise shift operators and zero fill",
"[vpEndian_test]")
68 for (uint16_t i = 0; i < 60000; i += 500) {
69 REQUIRE(((i >> 8) & 0x00FF) == (i >> 8));
73 int main(
int argc,
char *argv[])
75 #if defined(VISP_LITTLE_ENDIAN)
76 std::cout <<
"Detected endianess: LE" << std::endl;
77 #elif defined(VISP_BIG_ENDIAN)
78 std::cout <<
"Detected endianess: BE" << std::endl;
79 #elif defined(VISP_PDB_ENDIAN)
80 std::cout <<
"Detected endianess: PDB" << std::endl;
82 std::cout <<
"Detected endianess: unknown" << std::endl;
85 Catch::Session session;
86 session.applyCommandLine(argc, argv);
87 int numFailed = session.run();
92 int main() {
return EXIT_SUCCESS; }
VISP_EXPORT uint16_t reinterpret_cast_uchar_to_uint16_LE(unsigned char *const ptr)