错误处理机制纠正

This commit is contained in:
2026-08-16 03:34:17 +08:00
parent 893be8d2c6
commit b48a70515f
91 changed files with 1983 additions and 1516 deletions
@@ -3,7 +3,6 @@
#include <algorithm>
#include <array>
#include <limits>
#include <stdexcept>
namespace renderive {
namespace {
TEST(Renderive_Core2_Frame_Pipeline, ManualLifecycleSeparatesPrepareRefreshAndRender) {
@@ -39,7 +38,7 @@ TEST(Renderive_Core2_Frame_Pipeline, HighFrequencyLowLatencyLifecycleExposesKern
Plot_Scene plot;
plot.init();
plot.set_viewport_size({96, 54});
plot.set_max_render_fps(1'000'000'000.0);
EXPECT_EQ(plot.set_max_render_fps(1'000'000'000.0), Plot_Control_Error::none);
ASSERT_TRUE(plot.prepare_frame());
auto snapshot = plot.frame_status();
EXPECT_EQ(snapshot.last_event, "published");
@@ -72,8 +71,8 @@ TEST(Renderive_Core2_Frame_Pipeline, LowLatencyConsumerFeedbackFlowsThroughCore2
Plot_Scene plot;
plot.init();
plot.set_viewport_size({96, 54});
plot.set_max_render_fps(100.0);
plot.set_consumer_feedback({40'000'000});
EXPECT_EQ(plot.set_max_render_fps(100.0), Plot_Control_Error::none);
EXPECT_EQ(plot.set_consumer_feedback({40'000'000}), Plot_Control_Error::none);
ASSERT_TRUE(plot.prepare_frame());
ASSERT_TRUE(plot.render_prepared_frame());
const auto snapshot = plot.frame_status();
@@ -93,8 +92,8 @@ TEST(Renderive_Core2_Frame_Pipeline, LowLatencyLimitsCanBeClearedIndependently)
Plot_Scene plot;
plot.init();
plot.set_viewport_size({96, 54});
plot.set_max_render_fps(100.0);
plot.set_consumer_feedback({40'000'000});
EXPECT_EQ(plot.set_max_render_fps(100.0), Plot_Control_Error::none);
EXPECT_EQ(plot.set_consumer_feedback({40'000'000}), Plot_Control_Error::none);
plot.clear_consumer_feedback();
plot.clear_max_render_fps();
ASSERT_TRUE(plot.prepare_frame());
@@ -250,18 +249,18 @@ TEST(Renderive_Core2_Frame_Pipeline, EveryModeHonorsActiveDirtyAndForceRenderGat
}
TEST(Renderive_Core2_Frame_Pipeline, FrequencyConfigurationRejectsInvalidValuesAndWrongModes) {
Plot_Scene low_latency;
EXPECT_THROW(low_latency.set_max_render_fps(0.0), std::invalid_argument);
EXPECT_THROW(low_latency.set_max_render_fps(-1.0), std::invalid_argument);
EXPECT_THROW(low_latency.set_max_render_fps(std::numeric_limits<double>::quiet_NaN()),
std::invalid_argument);
EXPECT_THROW(low_latency.set_max_render_fps(std::numeric_limits<double>::infinity()),
std::invalid_argument);
low_latency.set_max_render_fps(1'000.0);
EXPECT_EQ(low_latency.set_max_render_fps(0.0), Plot_Control_Error::invalid_max_render_fps);
EXPECT_EQ(low_latency.set_max_render_fps(-1.0), Plot_Control_Error::invalid_max_render_fps);
EXPECT_EQ(low_latency.set_max_render_fps(std::numeric_limits<double>::quiet_NaN()),
Plot_Control_Error::invalid_max_render_fps);
EXPECT_EQ(low_latency.set_max_render_fps(std::numeric_limits<double>::infinity()),
Plot_Control_Error::invalid_max_render_fps);
EXPECT_EQ(low_latency.set_max_render_fps(1'000.0), Plot_Control_Error::none);
EXPECT_DOUBLE_EQ(low_latency.max_render_fps(), 1'000.0);
Plot_Scene manual({.frame_mode = Plot_Frame_Mode::Manual});
Plot_Scene playback({.frame_mode = Plot_Frame_Mode::Playback});
EXPECT_THROW(manual.set_max_render_fps(60.0), std::logic_error);
EXPECT_THROW(playback.set_max_render_fps(60.0), std::logic_error);
EXPECT_EQ(manual.set_max_render_fps(60.0), Plot_Control_Error::unsupported_frame_mode);
EXPECT_EQ(playback.set_max_render_fps(60.0), Plot_Control_Error::unsupported_frame_mode);
EXPECT_FALSE(playback.refresh_manual_frame());
EXPECT_FALSE(playback.discard_pending_frame());
}