From 58842bab05d0ce9208239da97f886a27233e4fe2 Mon Sep 17 00:00:00 2001 From: peachismomo Date: Sun, 27 Sep 2026 17:29:01 +0800 Subject: [PATCH] test: test for SliceStarted ensuring stable model ID is presetn when model name is absent --- tests/fff_print/test_print.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/fff_print/test_print.cpp b/tests/fff_print/test_print.cpp index 83dbfa0945..32cd608b43 100644 --- a/tests/fff_print/test_print.cpp +++ b/tests/fff_print/test_print.cpp @@ -280,6 +280,26 @@ TEST_CASE("Slicing lifecycle events identify the model", "[Print][LifecycleEvent } } +TEST_CASE("Slicing lifecycle event name is empty without model metadata", "[Print][LifecycleEvents]") +{ + std::string event_id; + std::string event_name = "unset"; + ScopedLifecycleHook hook([&](LifecycleEvent event, const LifecycleEventContext& ctx) { + if (event == LifecycleEvent::SliceStarted) { + event_id = ctx.id; + event_name = ctx.name; + } + }); + + Print print; + Model model; + init_print({cube(20)}, print, model); + print.process(); + + CHECK(event_id == std::to_string(print.model().id().id)); + CHECK(event_name.empty()); +} + TEST_CASE("Output filenames with numeric statistics fail before slicing finishes", "[Print][Regression]") { DynamicPrintConfig config = DynamicPrintConfig::full_print_config();