1
0
mirror of synced 2024-12-11 23:46:00 +01:00
ImHex/tests/algorithms/source/endian.cpp
RoboSchmied cc593fb6c4
fix: Misspelling of Endianness (#1609)
### Problem description
fix 40 typos

### Implementation description
`endianess` => `endianness`

Signed-off-by: RoboSchmied <github@roboschmie.de>
2024-03-28 22:25:28 +01:00

22 lines
718 B
C++

#include <hex/helpers/utils.hpp>
#include <hex/test/test_provider.hpp>
#include <hex/test/tests.hpp>
TEST_SEQUENCE("32BitIntegerEndianSwap") {
TEST_ASSERT(hex::changeEndianness<u32>(0xAABBCCDD, std::endian::big) == 0xDDCCBBAA);
TEST_SUCCESS();
};
TEST_SEQUENCE("64BitFloatEndianSwap") {
double floatValue = 1234.5;
u64 integerValue = reinterpret_cast<u64 &>(floatValue);
double swappedFloatValue = hex::changeEndianness(floatValue, std::endian::big);
u64 swappedIntegerValue = hex::changeEndianness(integerValue, std::endian::big);
TEST_ASSERT(std::memcmp(&floatValue, &integerValue, 8) == 0 && std::memcmp(&swappedFloatValue, &swappedIntegerValue, 8) == 0);
TEST_SUCCESS();
};