#include <iostream>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpEndian.h>
#if defined(VISP_HAVE_EIGEN3) && defined(VISP_HAVE_CATCH2)
#include <catch_amalgamated.hpp>
#ifdef ENABLE_VISP_NAMESPACE
#endif
TEST_CASE("Test reinterpret_cast_uchar_to_uint16_LE", "[vpEndian_test]")
{
unsigned char bitmap[] = { 100, 110, 120, 130 };
CHECK((val01 & 0x00FF) == bitmap[0]);
CHECK(((val01 & 0xFF00) >> 8) == bitmap[1]);
CHECK((val01 >> 8) == bitmap[1]);
CHECK((val12 & 0x00FF) == bitmap[2]);
CHECK(((val12 & 0xFF00) >> 8) == bitmap[3]);
CHECK((val12 >> 8) == bitmap[3]);
}
TEST_CASE("Test bitwise shift operators and zero fill", "[vpEndian_test]")
{
for (uint16_t i = 0; i < 60000; i += 500) {
REQUIRE(((i >> 8) & 0x00FF) == (i >> 8));
}
}
int main(int argc, char *argv[])
{
#if defined(VISP_LITTLE_ENDIAN)
std::cout << "Detected endianess: LE" << std::endl;
#elif defined(VISP_BIG_ENDIAN)
std::cout << "Detected endianess: BE" << std::endl;
#elif defined(VISP_PDB_ENDIAN)
std::cout << "Detected endianess: PDB" << std::endl;
#else
std::cout << "Detected endianess: unknown" << std::endl;
#endif
Catch::Session session;
session.applyCommandLine(argc, argv);
int numFailed = session.run();
return numFailed;
}
#else
int main() { return EXIT_SUCCESS; }
#endif
VISP_EXPORT uint16_t reinterpret_cast_uchar_to_uint16_LE(unsigned char *const ptr)