MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / TEST

Function TEST

tests/gtest_exception_tracking.cpp:63–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61};
62
63TEST(ExceptionTracking, BasicExceptionCapture)
64{
65 // Simple tree: Sequence -> ThrowingAction
66 const char* xml = R"(
67 <root BTCPP_format="4">
68 <BehaviorTree ID="MainTree">
69 <ThrowingAction name="thrower"/>
70 </BehaviorTree>
71 </root>
72 )";
73
74 BehaviorTreeFactory factory;
75 factory.registerNodeType<ThrowingAction>("ThrowingAction");
76
77 auto tree = factory.createTreeFromText(xml);
78
79 try
80 {
81 tree.tickOnce();
82 FAIL() << "Expected NodeExecutionError to be thrown";
83 }
84 catch(const NodeExecutionError& e)
85 {
86 // Verify the failed node info
87 EXPECT_EQ(e.failedNode().node_name, "thrower");
88 EXPECT_EQ(e.failedNode().registration_name, "ThrowingAction");
89 EXPECT_EQ(e.originalMessage(), "Test exception from ThrowingAction");
90 }
91}
92
93TEST(ExceptionTracking, NestedExceptionBacktrace)
94{

Callers

nothing calls this directly

Calls 4

createTreeFromTextMethod · 0.80
tickOnceMethod · 0.80
whatMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected