feat(solver-bootstrap): step 3 — core-ids-and-diagnostics
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#include <cstdint>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <fesa/core/entity_id.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
struct NodeTag;
|
||||
struct ElementTag;
|
||||
|
||||
using NodeId = fesa::EntityId<NodeTag>;
|
||||
using ElementId = fesa::EntityId<ElementTag>;
|
||||
|
||||
static_assert(std::is_constructible_v<NodeId, std::int64_t>);
|
||||
static_assert(!std::is_convertible_v<std::int64_t, NodeId>);
|
||||
static_assert(!std::is_convertible_v<NodeId, ElementId>);
|
||||
|
||||
TEST(EntityId, PreservesValueAndSupportsTypedOrdering) {
|
||||
constexpr NodeId first{7};
|
||||
constexpr NodeId second{11};
|
||||
|
||||
static_assert(first.value() == 7);
|
||||
static_assert(first < second);
|
||||
|
||||
EXPECT_EQ(first.value(), 7);
|
||||
EXPECT_LT(first, second);
|
||||
}
|
||||
|
||||
TEST(EntityId, RejectsNegativeValues) {
|
||||
EXPECT_THROW((NodeId{-1}), std::invalid_argument);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user