mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-26 20:38:45 +08:00
Storage type to unsigned char
This commit is contained in:
parent
8382606b7b
commit
7a1f9f961e
@ -231,8 +231,13 @@ namespace etl
|
||||
|
||||
typedef T value_type;
|
||||
|
||||
typedef typename private_unaligned_type::unaligned_type_common<sizeof(T)>::pointer pointer;
|
||||
typedef typename private_unaligned_type::unaligned_type_common<sizeof(T)>::const_pointer const_pointer;
|
||||
typedef typename private_unaligned_type::unaligned_type_common<sizeof(T)>::storage_type storage_type;
|
||||
typedef typename private_unaligned_type::unaligned_type_common<sizeof(T)>::pointer pointer;
|
||||
typedef typename private_unaligned_type::unaligned_type_common<sizeof(T)>::const_pointer const_pointer;
|
||||
typedef typename private_unaligned_type::unaligned_type_common<sizeof(T)>::iterator iterator;
|
||||
typedef typename private_unaligned_type::unaligned_type_common<sizeof(T)>::const_iterator const_iterator;
|
||||
typedef typename private_unaligned_type::unaligned_type_common<sizeof(T)>::reverse_iterator reverse_iterator;
|
||||
typedef typename private_unaligned_type::unaligned_type_common<sizeof(T)>::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
static ETL_CONSTANT int Endian = Endian_;
|
||||
static ETL_CONSTANT size_t Size = private_unaligned_type::unaligned_type_common<sizeof(T)>::Size;
|
||||
@ -363,7 +368,8 @@ namespace etl
|
||||
struct unaligned_copy;
|
||||
|
||||
//*******************************************
|
||||
// Size == 1
|
||||
/// Unaligned copy
|
||||
/// Size == 1
|
||||
//*******************************************
|
||||
template <typename U>
|
||||
struct unaligned_copy<U, 1U>
|
||||
@ -388,7 +394,8 @@ namespace etl
|
||||
};
|
||||
|
||||
//*******************************************
|
||||
// Size == 2
|
||||
/// Unaligned copy
|
||||
/// Size == 2
|
||||
//*******************************************
|
||||
template <typename U>
|
||||
struct unaligned_copy<U, 2U>
|
||||
@ -440,7 +447,8 @@ namespace etl
|
||||
};
|
||||
|
||||
//*******************************************
|
||||
// Size == 4
|
||||
/// Unaligned copy
|
||||
/// Size == 4
|
||||
//*******************************************
|
||||
template <typename U>
|
||||
struct unaligned_copy<U, 4U>
|
||||
@ -503,7 +511,8 @@ namespace etl
|
||||
};
|
||||
|
||||
//*******************************************
|
||||
// Size == 8
|
||||
/// Unaligned copy
|
||||
/// Size == 8
|
||||
//*******************************************
|
||||
template <typename U>
|
||||
struct unaligned_copy<U, 8U>
|
||||
|
||||
@ -760,5 +760,23 @@ namespace
|
||||
CHECK_EQUAL(0x1234, test_le.value());
|
||||
CHECK_EQUAL(0x1234, test_be.value());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_storage_bytes)
|
||||
{
|
||||
etl::le_uint16_t test_le(0x1234);
|
||||
etl::be_uint16_t test_be(0x1234);
|
||||
|
||||
int lev0 = test_le[0];
|
||||
int lev1 = test_le[1];
|
||||
|
||||
int bev0 = test_be[0];
|
||||
int bev1 = test_be[1];
|
||||
|
||||
CHECK_EQUAL(0x34, lev0);
|
||||
CHECK_EQUAL(0x12, lev1);
|
||||
CHECK_EQUAL(0x12, bev0);
|
||||
CHECK_EQUAL(0x34, bev1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -544,8 +544,8 @@ namespace
|
||||
{
|
||||
static constexpr etl::be_uint16_t test(0x1234);
|
||||
|
||||
constexpr const char* p1 = test.data();
|
||||
constexpr const char* p2 = test.data() + 1U;
|
||||
constexpr etl::be_uint16_t::const_pointer p1 = test.data();
|
||||
constexpr etl::be_uint16_t::const_pointer p2 = test.data() + 1U;
|
||||
|
||||
CHECK_EQUAL(0x12, *p1);
|
||||
CHECK_EQUAL(0x34, *p2);
|
||||
@ -618,5 +618,23 @@ namespace
|
||||
CHECK_EQUAL(0x1234, lev);
|
||||
CHECK_EQUAL(0x1234, bev);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_storage_bytes)
|
||||
{
|
||||
constexpr etl::le_uint16_t test_le(0x1234);
|
||||
constexpr etl::be_uint16_t test_be(0x1234);
|
||||
|
||||
constexpr int lev0 = test_le[0];
|
||||
constexpr int lev1 = test_le[1];
|
||||
|
||||
constexpr int bev0 = test_be[0];
|
||||
constexpr int bev1 = test_be[1];
|
||||
|
||||
CHECK_EQUAL(0x34, lev0);
|
||||
CHECK_EQUAL(0x12, lev1);
|
||||
CHECK_EQUAL(0x12, bev0);
|
||||
CHECK_EQUAL(0x34, bev1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user