diff --git a/tests/auto/plugins/pol/poltest.cpp b/tests/auto/plugins/pol/poltest.cpp index 11cd5ce..ec4d6ac 100644 --- a/tests/auto/plugins/pol/poltest.cpp +++ b/tests/auto/plugins/pol/poltest.cpp @@ -53,8 +53,8 @@ void PolTest::endianness() void PolTest::bufferToIntegralLe() { std::stringstream buffer; - char tmp[4] = { 0x12, 0x34, 0x56, 0x78 }; - const uint32_t &num = *reinterpret_cast(&tmp[0]); + char tmp[4] = { 0x78, 0x56, 0x34, 0x12 }; + const uint32_t num = (pol::getEndianess() == pol::Endian::LittleEndian) ? 0x12345678 : 0x78563412; buffer.write(tmp, 4); buffer.seekg(0); @@ -68,15 +68,14 @@ void PolTest::bufferToIntegralBe() { std::stringstream buffer; char tmp[4] = { 0x12, 0x34, 0x56, 0x78 }; - const uint32_t &num = *reinterpret_cast(&tmp[0]); + const uint32_t num = (pol::getEndianess() == pol::Endian::LittleEndian) ? 0x12345678 : 0x78563412; uint32_t result; - buffer.write(reinterpret_cast(&num), 4); + buffer.write(tmp, 4); buffer.seekg(0); result = pol::readIntegralFromBuffer(buffer); - std::reverse(tmp, tmp + 4); QCOMPARE(result, num); }