Do compile time checks in compile time instead of tests

check_span
elsid 3 years ago
parent c42c0dcbc9
commit da0a1ac9ba
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -87,20 +87,6 @@ TEST(EsmFixedString, empty_strings)
}
}
TEST(EsmFixedString, struct_size)
{
ASSERT_EQ(4, sizeof(ESM::NAME));
ASSERT_EQ(32, sizeof(ESM::NAME32));
ASSERT_EQ(64, sizeof(ESM::NAME64));
}
TEST(EsmFixedString, is_pod)
{
ASSERT_TRUE(std::is_standard_layout_v<ESM::NAME> && std::is_trivial_v<ESM::NAME>);
ASSERT_TRUE(std::is_standard_layout_v<ESM::NAME32> && std::is_trivial_v<ESM::NAME32>);
ASSERT_TRUE(std::is_standard_layout_v<ESM::NAME64> && std::is_trivial_v<ESM::NAME64>);
}
TEST(EsmFixedString, assign_should_zero_untouched_bytes_for_4)
{
ESM::NAME value;

@ -8,6 +8,7 @@
#include <cstdint>
#include <cassert>
#include <limits>
#include <type_traits>
namespace ESM
{
@ -171,6 +172,14 @@ using NAME = FixedString<4>;
using NAME32 = FixedString<32>;
using NAME64 = FixedString<64>;
static_assert(std::is_standard_layout_v<NAME> && std::is_trivial_v<NAME>);
static_assert(std::is_standard_layout_v<NAME32> && std::is_trivial_v<NAME32>);
static_assert(std::is_standard_layout_v<NAME64> && std::is_trivial_v<NAME64>);
static_assert(sizeof(NAME) == 4);
static_assert(sizeof(NAME32) == 32);
static_assert(sizeof(NAME64) == 64);
/* This struct defines a file 'context' which can be saved and later
restored by an ESMReader instance. It will save the position within
a file, and when restored will let you read from that position as

Loading…
Cancel
Save