File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#pragma once
22
3+ #include < algorithm>
4+ #include < cctype>
35#include < chrono>
46#include < iostream>
57#include < functional>
@@ -447,6 +449,12 @@ template <typename T = AnyTypeAllowed>
447449 " and must start with an alphabetic character. "
448450 " Underscore is reserved." );
449451 }
452+ if (std::any_of (sname.begin (), sname.end (),
453+ [](unsigned char c) { return std::isspace (c); }))
454+ {
455+ throw RuntimeError (
456+ StrCat (" The name of a port must not contain whitespace: '" , sname, " '" ));
457+ }
450458
451459 std::pair<std::string, PortInfo> out;
452460
Original file line number Diff line number Diff line change @@ -861,3 +861,13 @@ TEST(PortTest, VectorAny)
861861 ASSERT_NO_THROW (status = tree.tickOnce ());
862862 ASSERT_EQ (status, NodeStatus::FAILURE);
863863}
864+
865+ TEST (PortTest, WhitespaceInPortName)
866+ {
867+ ASSERT_ANY_THROW (BT::InputPort<std::string>(" port name" ));
868+ ASSERT_ANY_THROW (BT::InputPort<std::string>(" port\t name" ));
869+ ASSERT_ANY_THROW (BT::InputPort<std::string>(" port\n name" ));
870+ ASSERT_ANY_THROW (BT::InputPort<std::string>(" leading" ));
871+ ASSERT_ANY_THROW (BT::InputPort<std::string>(" trailing " ));
872+ ASSERT_NO_THROW (BT::InputPort<std::string>(" valid_port_name" ));
873+ }
You can’t perform that action at this time.
0 commit comments