Files
Renderive/Kernel/tests/renderive/base/property/Property_Builder_Test.cpp
T
2026-08-18 08:49:09 +08:00

32 lines
1.2 KiB
C++

#include <gtest/gtest.h>
#include <memory>
#include "Property_Test_Types.hpp"
TEST(property_builder_test, builds_independent_product) {
auto product = Property_Direct_Builder{7}
.set<&Property_Direct_Properties::value>(42)
.build();
EXPECT_EQ(product->value, 42);
EXPECT_EQ(product->id, 7);
}
TEST(property_builder_test, configures_properties) {
auto product = Property_Direct_Builder{1}
.set<&Property_Direct_Properties::value>(10)
.configure([](Property_Direct_Properties& properties) {
properties.value += 5;
})
.build();
EXPECT_EQ(product->value, 15);
}
TEST(property_builder_test, supports_external_validator) {
auto builder = Property_External_Product::Builder{}.set<&Property_External_Properties::minimum>(10).set<&Property_External_Properties::maximum>(5);
EXPECT_THROW(builder.build(), std::invalid_argument);
}
TEST(property_builder_test, builds_unique_product) {
auto product = Property_Direct_Builder{3}
.set<&Property_Direct_Properties::value>(12)
.build_unique();
static_assert(std::same_as<decltype(product), std::unique_ptr<Property_Direct_Product>>);
EXPECT_EQ(product->value, 12);
EXPECT_EQ(product->id, 3);
}