Added extra tests for as_bytes and as_writable_bytes

This commit is contained in:
John Wellbelove 2024-05-31 11:59:36 +01:00
parent f5f6bb3305
commit 931a1e6ed5
2 changed files with 32 additions and 0 deletions

View File

@ -1187,6 +1187,22 @@ namespace
CHECK_EQUAL(const_bytes.size(), sizeof(data));
CHECK_EQUAL(writable_bytes.size(), sizeof(data));
etl::byte* pdata = reinterpret_cast<etl::byte*>(data);
// Test the reading of bytes.
for (size_t i = 0; i < sizeof(data); ++i)
{
CHECK_EQUAL(int(pdata[i]), int(const_bytes[i]));
CHECK_EQUAL(int(pdata[i]), int(writable_bytes[i]));
}
// Test writing of bytes.
for (size_t i = 0; i < writable_bytes.size(); ++i)
{
writable_bytes[i] = ~writable_bytes[i];
CHECK_EQUAL(int(pdata[i]), int(writable_bytes[i]));
}
}
#include "etl/private/diagnostic_pop.h"

View File

@ -1105,6 +1105,22 @@ namespace
CHECK_EQUAL(const_bytes.size(), sizeof(data));
CHECK_EQUAL(writable_bytes.size(), sizeof(data));
etl::byte* pdata = reinterpret_cast<etl::byte*>(data);
// Test the reading of bytes.
for (size_t i = 0; i < sizeof(data); ++i)
{
CHECK_EQUAL(int(pdata[i]), int(const_bytes[i]));
CHECK_EQUAL(int(pdata[i]), int(writable_bytes[i]));
}
// Test writing of bytes.
for (size_t i = 0; i < writable_bytes.size(); ++i)
{
writable_bytes[i] = ~writable_bytes[i];
CHECK_EQUAL(int(pdata[i]), int(writable_bytes[i]));
}
}
#include "etl/private/diagnostic_pop.h"