35 lines
1.6 KiB
C++
35 lines
1.6 KiB
C++
#include <render_2D/module/plottable/common/Curve_Plot.hpp>
|
|
#include <render_2D/module/plottable/common/Raster_Plot.hpp>
|
|
#include <gtest/gtest.h>
|
|
#include <vector>
|
|
namespace {
|
|
using namespace aethera::render_2d;
|
|
|
|
TEST(Partition_Configuration, Curve_Partitions_Share_Only_Boundary_Samples) {
|
|
constexpr Axis_Range domain{0.0, 100.0};
|
|
const auto first = detail::curve_partition_range(11, 0, 2, domain);
|
|
const auto second = detail::curve_partition_range(11, 1, 2, domain);
|
|
EXPECT_EQ(first.first_sample + first.sample_count - 1, second.first_sample);
|
|
EXPECT_EQ(first.domain.target, second.domain.origin);
|
|
}
|
|
|
|
TEST(Partition_Configuration, Raster_Grid_Covers_Each_Cell_Exactly_Once) {
|
|
const detail::Raster_Layout layout{7, 5, Rect_F{0.0, 0.0, 140.0, 100.0}, true, true, false};
|
|
const Plot_Partition_Grid grid{3, 2};
|
|
std::vector<unsigned> visits(static_cast<std::size_t>(layout.width) * layout.height);
|
|
for (Plot_Partition_Count index = 0; index < detail::raster_partition_count(grid); ++index) {
|
|
const auto partition = detail::raster_partition(layout, index, grid);
|
|
EXPECT_FALSE(partition.empty());
|
|
for (int y = partition.first_y; y < partition.last_y; ++y)
|
|
for (int x = partition.first_x; x < partition.last_x; ++x) ++visits[static_cast<std::size_t>(y) * layout.width + x];
|
|
}
|
|
for (const auto count : visits) EXPECT_EQ(count, 1U);
|
|
}
|
|
|
|
TEST(Partition_Configuration, Color_Map_Clamps_Outside_The_Domain) {
|
|
const Color_Map map;
|
|
EXPECT_EQ(map.sample(-1.0), map.stops.front());
|
|
EXPECT_EQ(map.sample(2.0), map.stops.back());
|
|
}
|
|
} // namespace
|