46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
#include "render_3D/Point_Visual.h"
|
|
#include <gtest/gtest.h>
|
|
#include <array>
|
|
#include <vector>
|
|
|
|
namespace renderive::render_3d {
|
|
namespace {
|
|
|
|
TEST(PointState, BuilderAndStateMutationShareOneAuthoritativeState) {
|
|
Point_State initial;
|
|
initial.style.stroke_width_px = 2.0F;
|
|
auto visual = Point_Visual::Builder(
|
|
std::vector<Point>{{{1.0F, 2.0F, 3.0F}, {1, 2, 3, 255}, 7.0F}})
|
|
.configure([&](Point_Visual::Properties& properties) {
|
|
properties = initial;
|
|
})
|
|
.build();
|
|
ASSERT_TRUE(visual);
|
|
EXPECT_EQ(visual->get<&Point_State::style>(), initial.style);
|
|
auto changed = initial.style;
|
|
changed.stroke_width_px = 3.0F;
|
|
visual->set<&Point_State::style>(changed);
|
|
EXPECT_EQ(visual->get<&Point_State::style>(), changed);
|
|
}
|
|
|
|
TEST(PointState, BulkUpdatesUseOwnedStorage) {
|
|
auto visual = Point_Visual::Builder{}.build();
|
|
ASSERT_TRUE(visual);
|
|
EXPECT_EQ(visual->update_points(std::vector<Point>(4)),
|
|
Visual_Data_Error::none);
|
|
EXPECT_EQ(visual->point_count(), 4U);
|
|
}
|
|
|
|
TEST(PointState, RejectsInvalidStateAndPayloadAtOwningBoundary) {
|
|
auto visual = Point_Visual::Builder{}.build();
|
|
Point_State invalid;
|
|
invalid.style.stroke_width_px = -1.0F;
|
|
EXPECT_THROW(visual->set<&Point_State::style>(invalid.style),
|
|
std::invalid_argument);
|
|
EXPECT_EQ(visual->update_points(std::vector<Point>{{{}, {}, 0.0F}}),
|
|
Visual_Data_Error::invalid_data);
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace renderive::render_3d
|