37 #include <visp3/core/vpConfig.h> 38 #include <visp3/core/vpEndian.h> 40 #if defined(VISP_HAVE_EIGEN3) && defined(VISP_HAVE_CATCH2) 41 #define CATCH_CONFIG_RUNNER 44 TEST_CASE(
"Test reinterpret_cast_uchar_to_uint16_LE",
"[vpEndian_test]") {
45 unsigned char bitmap[] = {100, 110, 120, 130};
49 CHECK((val01 & 0x00FF) == bitmap[0]);
50 CHECK(((val01 & 0xFF00) >> 8) == bitmap[1]);
51 CHECK((val01 >> 8) == bitmap[1]);
53 CHECK((val12 & 0x00FF) == bitmap[2]);
54 CHECK(((val12 & 0xFF00) >> 8) == bitmap[3]);
55 CHECK((val12 >> 8)== bitmap[3]);
58 TEST_CASE(
"Test bitwise shift operators and zero fill",
"[vpEndian_test]") {
61 for (uint16_t i = 0; i < 60000; i += 500) {
62 REQUIRE(((i >> 8) & 0x00FF) == (i >> 8));
66 int main(
int argc,
char *argv[])
68 #if defined(VISP_LITTLE_ENDIAN) 69 std::cout <<
"Detected endianess: LE" << std::endl;
70 #elif defined(VISP_BIG_ENDIAN) 71 std::cout <<
"Detected endianess: BE" << std::endl;
72 #elif defined(VISP_PDB_ENDIAN) 73 std::cout <<
"Detected endianess: PDB" << std::endl;
75 std::cout <<
"Detected endianess: unknown" << std::endl;
78 Catch::Session session;
81 session.applyCommandLine(argc, argv);
83 int numFailed = session.run();
VISP_EXPORT uint16_t reinterpret_cast_uchar_to_uint16_LE(unsigned char *const ptr)