25 lines
1.1 KiB
C++
25 lines
1.1 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{Property_Direct_Properties{.value = 42}}.build(7);
|
|
EXPECT_EQ(product->value, 42);
|
|
EXPECT_EQ(product->id, 7);
|
|
}
|
|
TEST(property_builder_test, configures_properties) {
|
|
auto product = Property_Direct_Builder{}.set<&Property_Direct_Properties::value>(10).configure([](Property_Direct_Properties& properties) {
|
|
properties.value += 5;
|
|
}).build(1);
|
|
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{Property_Direct_Properties{.value = 12}}.build_unique(3);
|
|
static_assert(std::same_as<decltype(product), std::unique_ptr<Property_Direct_Product>>);
|
|
EXPECT_EQ(product->value, 12);
|
|
EXPECT_EQ(product->id, 3);
|
|
}
|