综合平台编程器项目的远程存储
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1098 line
47 KiB

  1. #include "domain/control_logic_model.h"
  2. #include "domain/hmi_control_registry.h"
  3. #include "domain/hmi_model.h"
  4. #include "domain/project_model.h"
  5. #include "domain/project_limits.h"
  6. #include "domain/register_address.h"
  7. #include "domain/register_repository.h"
  8. #include "domain/runtime_state.h"
  9. #include "domain/virtual_register_repository.h"
  10. #include "support/test_support.h"
  11. #include <algorithm>
  12. #include <cmath>
  13. #include <cstdint>
  14. #include <exception>
  15. #include <iostream>
  16. #include <limits>
  17. #include <set>
  18. #include <stdexcept>
  19. #include <string>
  20. namespace {
  21. using TestSupport::require;
  22. void testRegisterAddressBoundaries()
  23. {
  24. // 覆盖 M/D 地址允许范围及未知枚举值的拒绝路径
  25. require(RegisterAddress{RegisterArea::M, 0}.isValid(),
  26. "M0 must be valid");
  27. require(RegisterAddress{RegisterArea::D, 4000}.isValid(),
  28. "D4000 must be valid");
  29. require(!(RegisterAddress{RegisterArea::M, -1}.isValid()),
  30. "negative register index must be rejected");
  31. require(!(RegisterAddress{RegisterArea::D, 4001}.isValid()),
  32. "register index above 4000 must be rejected");
  33. require(!(RegisterAddress{static_cast<RegisterArea>(99), 0}.isValid()),
  34. "unknown register area must be rejected");
  35. }
  36. void testRegisterAddressParsing()
  37. {
  38. const RegisterAddressParseResult m0 = parseRegisterAddress(" m0 ");
  39. require(m0.succeeded && m0.address == RegisterAddress{RegisterArea::M, 0},
  40. "register parser must trim and normalize lowercase M addresses");
  41. const RegisterAddressParseResult d4000 = parseRegisterAddress("D4000");
  42. require(d4000.succeeded
  43. && d4000.address == RegisterAddress{RegisterArea::D, 4000},
  44. "register parser must accept the maximum D address");
  45. require(parseRegisterAddress("").error == RegisterAddressParseError::Empty,
  46. "register parser must distinguish empty input");
  47. require(parseRegisterAddress("X0").error
  48. == RegisterAddressParseError::UnsupportedArea,
  49. "register parser must reject unsupported areas");
  50. require(parseRegisterAddress("M1.0").error
  51. == RegisterAddressParseError::InvalidFormat,
  52. "register parser must reject non-decimal indices");
  53. require(parseRegisterAddress("D4001").error
  54. == RegisterAddressParseError::OutOfRange,
  55. "register parser must reject addresses above the project range");
  56. }
  57. void testRegisterRepositorySeparatesAreas()
  58. {
  59. // 验证离线仓库不会把 M 位和 D 字交叉解释
  60. VirtualRegisterRepository repository;
  61. const RegisterAddress m0{RegisterArea::M, 0};
  62. const RegisterAddress d0{RegisterArea::D, 0};
  63. require(repository.writeBit(m0, true).succeeded, "M bit write must succeed");
  64. require(repository.readBit(m0).value, "M bit read must return written value");
  65. require(repository.writeWord(d0, static_cast<std::int16_t>(-123)).succeeded,
  66. "D word write must succeed");
  67. require(repository.readWord(d0).value == -123, "D word read must return written value");
  68. require(repository.readBit(d0).error == RegisterError::AreaMismatch,
  69. "D address must not be read as a bit");
  70. require(repository.readWord(m0).error == RegisterError::AreaMismatch,
  71. "M address must not be read as a word");
  72. }
  73. void testMultiWordCodecsAndBlockAccess()
  74. {
  75. const std::array<std::int32_t, 4> int32_values = {
  76. std::numeric_limits<std::int32_t>::min(), -1, 0,
  77. std::numeric_limits<std::int32_t>::max()};
  78. for (const std::int32_t value : int32_values)
  79. {
  80. const std::array<std::int16_t, 2> words = Int32Codec::encode(value);
  81. require(Int32Codec::decode(words[0], words[1]) == value,
  82. "Int32 codec must preserve signed boundary values");
  83. }
  84. const std::array<std::int16_t, 2> int32_words =
  85. Int32Codec::encode(0x12345678);
  86. require(static_cast<std::uint16_t>(int32_words[0]) == 0x5678U
  87. && static_cast<std::uint16_t>(int32_words[1]) == 0x1234U,
  88. "Int32 codec must store the low 16-bit word at the lower D address");
  89. const std::array<float, 4> values = {1.0f, -2.5f, 0.1f, 0.0f};
  90. for (const float value : values)
  91. {
  92. const std::array<std::int16_t, 2> words = Float32Codec::encode(value);
  93. const std::optional<float> decoded = Float32Codec::decode(words[0], words[1]);
  94. require(decoded.has_value() && *decoded == value,
  95. "Float32 codec must preserve representative finite values");
  96. }
  97. require(!Float32Codec::decode(
  98. static_cast<std::int16_t>(0),
  99. static_cast<std::int16_t>(0x7f80)).has_value(),
  100. "Float32 codec must reject positive infinity");
  101. require(!Float32Codec::decode(
  102. static_cast<std::int16_t>(0),
  103. static_cast<std::int16_t>(0x7fc0)).has_value(),
  104. "Float32 codec must reject NaN");
  105. const std::array<std::int16_t, 2> float20 = Float32Codec::encode(20.0f);
  106. require(static_cast<std::uint16_t>(float20[0]) == 0x0000U
  107. && static_cast<std::uint16_t>(float20[1]) == 0x41a0U,
  108. "Float32 20.0 must match the Xinje low-word-first example");
  109. const std::array<double, 4> double_values = {1.0, -2.5, 0.1, 0.0};
  110. for (const double value : double_values)
  111. {
  112. const std::array<std::int16_t, 4> words = Float64Codec::encode(value);
  113. const std::optional<double> decoded = Float64Codec::decode(words);
  114. require(decoded.has_value() && *decoded == value,
  115. "Double codec must preserve representative finite values");
  116. }
  117. const std::array<std::int16_t, 4> double_one = Float64Codec::encode(1.0);
  118. require(static_cast<std::uint16_t>(double_one[0]) == 0x0000U
  119. && static_cast<std::uint16_t>(double_one[1]) == 0x0000U
  120. && static_cast<std::uint16_t>(double_one[2]) == 0x0000U
  121. && static_cast<std::uint16_t>(double_one[3]) == 0x3ff0U,
  122. "Double 1.0 must occupy four low-address-first D words");
  123. require(!Float64Codec::decode({
  124. static_cast<std::int16_t>(0), static_cast<std::int16_t>(0),
  125. static_cast<std::int16_t>(0), static_cast<std::int16_t>(0x7ff0)})
  126. .has_value()
  127. && !Float64Codec::decode({
  128. static_cast<std::int16_t>(0), static_cast<std::int16_t>(0),
  129. static_cast<std::int16_t>(0), static_cast<std::int16_t>(0x7ff8)})
  130. .has_value(),
  131. "Double codec must reject infinity and NaN bit patterns");
  132. require(encodeRegisterNumericValue(
  133. RegisterDataType::Int32,
  134. static_cast<double>(std::numeric_limits<std::int32_t>::min()))
  135. .has_value()
  136. && encodeRegisterNumericValue(
  137. RegisterDataType::Int32,
  138. static_cast<double>(std::numeric_limits<std::int32_t>::max()))
  139. .has_value()
  140. && !encodeRegisterNumericValue(
  141. RegisterDataType::Int32, 1.5).has_value()
  142. && !encodeRegisterNumericValue(
  143. RegisterDataType::Float64,
  144. std::numeric_limits<double>::infinity()).has_value()
  145. && !encodeRegisterNumericValue(
  146. RegisterDataType::Float64,
  147. std::numeric_limits<double>::quiet_NaN()).has_value(),
  148. "typed encoding must enforce Int32 integrality and finite Double values");
  149. VirtualRegisterRepository repository;
  150. const RegisterAddress d10{RegisterArea::D, 10};
  151. const auto float_words = Float32Codec::encode(-2.5f);
  152. require(repository.writeWords(
  153. d10, {float_words[0], float_words[1]}).succeeded,
  154. "virtual repository must write Float32 low and high words");
  155. const WordsReadResult pair = repository.readWords(d10, 2);
  156. require(pair.succeeded
  157. && Float32Codec::decode(pair.values[0], pair.values[1]).value() == -2.5f,
  158. "virtual repository must read Float32 from two consecutive words");
  159. require(!repository.writeWords({RegisterArea::D, 4000}, {}).succeeded,
  160. "Float32 write at D4000 must be rejected");
  161. require(repository.writeWords(
  162. {RegisterArea::D, 30},
  163. {double_one[0], double_one[1], double_one[2], double_one[3]})
  164. .succeeded
  165. && repository.readWords({RegisterArea::D, 30}, 4).values
  166. == std::vector<std::int16_t>(
  167. double_one.cbegin(), double_one.cend()),
  168. "virtual repository must read and write one complete four-word block");
  169. repository.writeWord({RegisterArea::D, 4000}, 77);
  170. require(!repository.writeWords(
  171. {RegisterArea::D, 4000}, {1, 2}).succeeded
  172. && repository.readWord({RegisterArea::D, 4000}).value == 77,
  173. "an overflowing block write must fail before changing any D word");
  174. RegisterDataType parsed = RegisterDataType::Int16;
  175. require(parseRegisterDataType("int32", &parsed)
  176. && parsed == RegisterDataType::Int32
  177. && parseRegisterDataType("float64", &parsed)
  178. && parsed == RegisterDataType::Float64
  179. && registerDataTypeWordCount(RegisterDataType::Float64) == 4,
  180. "register data type descriptors must expose Int32 and Float64 names");
  181. const RegisterDataType invalid_type = static_cast<RegisterDataType>(99);
  182. require(!registerDataTypeIsSupported(invalid_type)
  183. && registerDataTypeWordCount(invalid_type) == 0
  184. && !registerDataTypeAddressIsValid(
  185. invalid_type, {RegisterArea::D, 0}),
  186. "unknown register data types must not borrow Int16 rules");
  187. }
  188. void testHmiControlRegistryCompleteness()
  189. {
  190. std::set<const HmiControlDescriptor *> descriptors;
  191. std::set<std::string> storage_names;
  192. std::set<std::string> id_prefixes;
  193. const std::size_t control_type_count =
  194. static_cast<std::size_t>(HmiControlType::Count);
  195. for (std::size_t index = 0; index < control_type_count; ++index)
  196. {
  197. const HmiControlType type = static_cast<HmiControlType>(index);
  198. const HmiControlDescriptor *descriptor =
  199. findHmiControlDescriptor(type);
  200. require(descriptor != nullptr,
  201. "every HMI control type must have one descriptor");
  202. require(descriptor->type == type,
  203. "HMI type lookup must return the requested descriptor");
  204. require(descriptors.emplace(descriptor).second,
  205. "each HMI control type must resolve to a different descriptor");
  206. require(descriptor->storageName != nullptr
  207. && descriptor->storageName[0] != '\0',
  208. "HMI storage names must not be empty");
  209. require(descriptor->displayName != nullptr
  210. && descriptor->displayName[0] != '\0',
  211. "HMI display names must not be empty");
  212. require(descriptor->idPrefix != nullptr
  213. && descriptor->idPrefix[0] != '\0',
  214. "HMI id prefixes must not be empty");
  215. require(descriptor->defaultText != nullptr,
  216. "HMI default text must not be null");
  217. require(descriptor->defaultBounds.width > 0
  218. && descriptor->defaultBounds.height > 0,
  219. "HMI default bounds must have a positive size");
  220. require(findHmiControlDescriptor(descriptor->storageName) == descriptor,
  221. "HMI storage name lookup must return its registered descriptor");
  222. require(storage_names.emplace(descriptor->storageName).second,
  223. "HMI storage names must be unique");
  224. require(id_prefixes.emplace(descriptor->idPrefix).second,
  225. "HMI id prefixes must be unique");
  226. const std::optional<RegisterArea> binding_area =
  227. hmiBindingArea(descriptor->bindingKind);
  228. switch (descriptor->runtimeValueKind)
  229. {
  230. case HmiRuntimeValueKind::Bit:
  231. {
  232. require(descriptor->bindingKind == HmiBindingKind::Bit
  233. && binding_area == RegisterArea::M,
  234. "bit runtime controls must bind to the M area");
  235. break;
  236. }
  237. case HmiRuntimeValueKind::Word:
  238. {
  239. require(descriptor->bindingKind == HmiBindingKind::Word
  240. && binding_area == RegisterArea::D,
  241. "word runtime controls must bind to the D area");
  242. break;
  243. }
  244. case HmiRuntimeValueKind::BitOrWord:
  245. {
  246. require(descriptor->bindingKind == HmiBindingKind::BitOrWord
  247. && !binding_area.has_value(),
  248. "flexible runtime controls must choose M or D from their config");
  249. break;
  250. }
  251. case HmiRuntimeValueKind::None:
  252. {
  253. require(descriptor->bindingKind == HmiBindingKind::None
  254. && !binding_area.has_value(),
  255. "static controls must not declare a register binding");
  256. break;
  257. }
  258. }
  259. require(descriptor->requiresBindingForRunning
  260. == (descriptor->runtimeValueKind
  261. != HmiRuntimeValueKind::None),
  262. "runtime value controls must require a configured binding");
  263. }
  264. require(findHmiControlDescriptor(HmiControlType::Count) == nullptr,
  265. "the HMI control count marker must not be registered");
  266. require(findHmiControlDescriptor(static_cast<HmiControlType>(99)) == nullptr,
  267. "unknown HMI control types must not resolve");
  268. require(findHmiControlDescriptor("unknown") == nullptr,
  269. "unknown HMI storage names must not resolve");
  270. require(hmiBindingArea(HmiBindingKind::Bit) == RegisterArea::M,
  271. "bit bindings must use the M area");
  272. require(hmiBindingArea(HmiBindingKind::Word) == RegisterArea::D,
  273. "word bindings must use the D area");
  274. require(!hmiBindingArea(HmiBindingKind::None).has_value(),
  275. "controls without bindings must not resolve a register area");
  276. }
  277. Project makeValidProject();
  278. void testStatusTextDomainRules()
  279. {
  280. HmiControl status;
  281. status.id = "status";
  282. status.type = HmiControlType::StatusText;
  283. status.text = "Status";
  284. status.binding = RegisterAddress{RegisterArea::M, 0};
  285. status.statusText = HmiStatusBitTextConfig{"Stopped", "Running"};
  286. require(status.validate(), "M status text with OFF and ON labels must be valid");
  287. status.binding = RegisterAddress{RegisterArea::D, 0};
  288. require(!status.validate(), "M status text configuration must reject a D binding");
  289. status.binding = RegisterAddress{RegisterArea::D, 20};
  290. status.dataType = RegisterDataType::Float32;
  291. status.statusText = HmiStatusWordTextConfig{{
  292. {std::nullopt, 30.0, "Low"},
  293. {30.0, 80.0, "Normal"},
  294. {80.0, std::nullopt, "High"}}};
  295. require(status.validate(),
  296. "D status text must accept complete adjacent half-open ranges");
  297. status.binding.reset();
  298. require(status.validate(),
  299. "an unbound D status text draft must keep its selected data type");
  300. status.binding = RegisterAddress{RegisterArea::D, 20};
  301. const auto consecutive_ranges = [](std::size_t count)
  302. {
  303. std::vector<HmiStatusValueRange> result;
  304. result.reserve(count);
  305. for (std::size_t index = 0; index < count; ++index)
  306. {
  307. result.push_back({
  308. index == 0U
  309. ? std::optional<double>{}
  310. : std::optional<double>{static_cast<double>(index)},
  311. index + 1U == count
  312. ? std::optional<double>{}
  313. : std::optional<double>{static_cast<double>(index + 1U)},
  314. "State"});
  315. }
  316. return result;
  317. };
  318. status.statusText = HmiStatusWordTextConfig{
  319. consecutive_ranges(ProjectLimits::kMaximumStatusTextRanges)};
  320. require(status.validate(), "a status text control must accept 16 ranges");
  321. status.statusText = HmiStatusWordTextConfig{
  322. consecutive_ranges(ProjectLimits::kMaximumStatusTextRanges + 1U)};
  323. require(!status.validate(), "a status text control must reject a 17th range");
  324. status.statusText = HmiStatusWordTextConfig{{
  325. {std::nullopt, 30.0, "Low"},
  326. {30.0, 80.0, "Normal"},
  327. {80.0, std::nullopt, "High"}}};
  328. auto &ranges = std::get<HmiStatusWordTextConfig>(*status.statusText).ranges;
  329. ranges[1].lowerBound = 31.0;
  330. require(!status.validate(), "D status text must reject range gaps");
  331. ranges[1].lowerBound = 29.0;
  332. require(!status.validate(), "D status text must reject overlapping ranges");
  333. ranges[1].lowerBound = 30.0;
  334. ranges.front().lowerBound = -100.0;
  335. require(!status.validate(), "D status text must start with an unlimited lower bound");
  336. ranges.front().lowerBound.reset();
  337. status.dataType = RegisterDataType::Int32;
  338. ranges[1].upperBound = 80.5;
  339. require(!status.validate(), "integer status text boundaries must be integers");
  340. Project project = makeValidProject();
  341. status.dataType = RegisterDataType::Float64;
  342. status.binding = RegisterAddress{RegisterArea::D, 100};
  343. ranges[1].upperBound = 80.0;
  344. project.hmiPages.front().controls.push_back(status);
  345. HmiControl overlapping;
  346. overlapping.id = "overlapping";
  347. overlapping.type = HmiControlType::NumericDisplay;
  348. overlapping.text = "Overlap";
  349. overlapping.binding = RegisterAddress{RegisterArea::D, 102};
  350. project.hmiPages.front().controls.push_back(overlapping);
  351. require(!project.validate(defaultProjectLimitSettings()),
  352. "D status text must participate in multi-word HMI overlap checks");
  353. }
  354. void testMultiWordHmiBoundaries()
  355. {
  356. Project project = makeValidProject();
  357. HmiControl display;
  358. display.id = "float-display";
  359. display.type = HmiControlType::NumericDisplay;
  360. display.text = "Value";
  361. display.binding = RegisterAddress{RegisterArea::D, 3999};
  362. display.dataType = RegisterDataType::Float32;
  363. project.hmiPages.front().controls.push_back(display);
  364. require(project.validate(defaultProjectLimitSettings()),
  365. "Float32 D3999 must be valid and occupy D3999~D4000");
  366. project.hmiPages.front().controls.back().binding =
  367. RegisterAddress{RegisterArea::D, 4000};
  368. require(!project.validate(defaultProjectLimitSettings()), "Float32 D4000 must be rejected");
  369. project = makeValidProject();
  370. HmiControl int32_display = display;
  371. int32_display.id = "int32-display";
  372. int32_display.dataType = RegisterDataType::Int32;
  373. int32_display.binding = RegisterAddress{RegisterArea::D, 3999};
  374. project.hmiPages.front().controls.push_back(int32_display);
  375. require(project.validate(defaultProjectLimitSettings()), "Int32 D3999 must be valid");
  376. project.hmiPages.front().controls.back().binding =
  377. RegisterAddress{RegisterArea::D, 4000};
  378. require(!project.validate(defaultProjectLimitSettings()), "Int32 D4000 must be rejected");
  379. project = makeValidProject();
  380. HmiControl double_display = display;
  381. double_display.id = "double-display";
  382. double_display.dataType = RegisterDataType::Float64;
  383. double_display.binding = RegisterAddress{RegisterArea::D, 3996};
  384. project.hmiPages.front().controls.push_back(double_display);
  385. require(project.validate(defaultProjectLimitSettings()), "Double D3996 must be a valid even start address");
  386. project.hmiPages.front().controls.back().binding =
  387. RegisterAddress{RegisterArea::D, 3997};
  388. require(!project.validate(defaultProjectLimitSettings()), "Double D3997 must be rejected");
  389. project.hmiPages.front().controls.back().binding =
  390. RegisterAddress{RegisterArea::D, 3995};
  391. require(!project.validate(defaultProjectLimitSettings()), "Double odd start addresses must be rejected");
  392. project = makeValidProject();
  393. HmiControl invalid_display = display;
  394. invalid_display.id = "invalid-type-display";
  395. invalid_display.binding.reset();
  396. invalid_display.dataType = static_cast<RegisterDataType>(99);
  397. project.hmiPages.front().controls.push_back(invalid_display);
  398. require(!project.validate(defaultProjectLimitSettings()),
  399. "an unbound HMI draft must still reject an unknown numeric type");
  400. project = makeValidProject();
  401. HmiControl first = display;
  402. first.binding = RegisterAddress{RegisterArea::D, 10};
  403. HmiControl second = first;
  404. second.id = "float-display-duplicate";
  405. project.hmiPages.front().controls.push_back(first);
  406. project.hmiPages.front().controls.push_back(second);
  407. require(project.validate(defaultProjectLimitSettings()),
  408. "same Float32 start address and type may be bound more than once");
  409. second.dataType = RegisterDataType::Int16;
  410. project.hmiPages.front().controls.back() = second;
  411. require(!project.validate(defaultProjectLimitSettings()),
  412. "different HMI data types may not partially overlap");
  413. for (const RegisterDataType type : {
  414. RegisterDataType::Int32,
  415. RegisterDataType::Float32,
  416. RegisterDataType::Float64})
  417. {
  418. project = makeValidProject();
  419. HmiControl configured_multi_word = display;
  420. configured_multi_word.id = "protected-multi-word";
  421. configured_multi_word.dataType = type;
  422. configured_multi_word.binding = RegisterAddress{RegisterArea::D, 10};
  423. project.hmiPages.front().controls.push_back(configured_multi_word);
  424. project.controlLogics.front().rungs.front().output = LogicNode{
  425. "move-output",
  426. MoveNodeConfig{
  427. WordOperand{
  428. WordOperandKind::Constant,
  429. RegisterAddress{RegisterArea::D, 0},
  430. 1},
  431. RegisterAddress{
  432. RegisterArea::D,
  433. 10 + registerDataTypeWordCount(type) - 1}},
  434. true};
  435. require(!project.validate(defaultProjectLimitSettings()),
  436. "16-bit instructions must not write inside any multi-word HMI range");
  437. }
  438. }
  439. void testHmiAppearancePropertyBoundaries()
  440. {
  441. // 外观属性必须在领域层拒绝格式错误,但不能影响未知扩展属性
  442. Project project = makeValidProject();
  443. HmiControl &button = project.hmiPages.front().controls.front();
  444. button.properties[HmiAppearanceProperty::kTextColor] = "#E53935";
  445. button.properties[HmiAppearanceProperty::kFontSize] = "18";
  446. button.properties[HmiAppearanceProperty::kFontBold] = "true";
  447. button.properties[HmiAppearanceProperty::kFontItalic] = "false";
  448. require(project.validate(defaultProjectLimitSettings()), "valid HMI appearance properties must pass validation");
  449. button.properties[HmiAppearanceProperty::kTextColor] = "red";
  450. require(!project.validate(defaultProjectLimitSettings()), "text colors must use the #RRGGBB format");
  451. project = makeValidProject();
  452. HmiControl &font_control = project.hmiPages.front().controls.front();
  453. font_control.properties[HmiAppearanceProperty::kFontSize] = "5";
  454. require(!project.validate(defaultProjectLimitSettings()), "font sizes below the minimum must be rejected");
  455. font_control.properties[HmiAppearanceProperty::kFontSize] = "73";
  456. require(!project.validate(defaultProjectLimitSettings()), "font sizes above the maximum must be rejected");
  457. font_control.properties[HmiAppearanceProperty::kFontSize] = "large";
  458. require(!project.validate(defaultProjectLimitSettings()), "non-numeric font sizes must be rejected");
  459. project = makeValidProject();
  460. HmiControl &style_control = project.hmiPages.front().controls.front();
  461. style_control.properties[HmiAppearanceProperty::kFontBold] = "yes";
  462. require(!project.validate(defaultProjectLimitSettings()), "font style flags must be true or false");
  463. project = makeValidProject();
  464. project.hmiPages.front().controls.front().properties["legacyColor"] = "green";
  465. require(project.validate(defaultProjectLimitSettings()), "unknown HMI extension properties must remain supported");
  466. }
  467. Project makeValidProject()
  468. {
  469. // 构造包含 HMI 绑定和完整梯形图网络的最小合法工程作为测试基线
  470. HmiControl start_button;
  471. start_button.id = "start-button";
  472. start_button.type = HmiControlType::Button;
  473. start_button.text = "Start";
  474. start_button.binding = {RegisterArea::M, 0};
  475. HmiPage page;
  476. page.id = "main-page";
  477. page.name = "Main";
  478. page.controls.push_back(start_button);
  479. LogicNode contact;
  480. contact.id = "start-contact";
  481. contact.config = ContactNodeConfig{
  482. RegisterAddress{RegisterArea::M, 0},
  483. ContactMode::NormallyOpen};
  484. LogicNode coil;
  485. coil.id = "run-coil";
  486. coil.config = CoilNodeConfig{
  487. RegisterAddress{RegisterArea::M, 1},
  488. CoilMode::Normal};
  489. ControlLogic logic;
  490. logic.id = "start-logic";
  491. logic.name = "Start logic";
  492. LadderRung rung;
  493. rung.id = "rung-1";
  494. rung.name = "Network 1";
  495. for (int column = 0;
  496. column < ProjectLimits::kMaximumConditionColumns;
  497. ++column)
  498. {
  499. rung.cells.push_back({
  500. "start-cell-" + std::to_string(column),
  501. column == 0 ? LadderCellKind::Node : LadderCellKind::Wire,
  502. column == 0 ? std::optional<LogicNode>{contact} : std::nullopt});
  503. }
  504. rung.output = coil;
  505. logic.rungs.push_back(rung);
  506. Project project;
  507. project.metadata = {"sample-project", "Sample project", "3.0"};
  508. project.hmiPages.push_back(page);
  509. project.initialHmiPageId = page.id;
  510. project.controlLogics.push_back(logic);
  511. return project;
  512. }
  513. void testMultiPageAndLogicDomainRules()
  514. {
  515. Project project = makeValidProject();
  516. HmiPage settings;
  517. settings.id = "settings-page";
  518. settings.name = "Settings";
  519. project.hmiPages.push_back(settings);
  520. HmiControl label;
  521. label.id = "title";
  522. label.type = HmiControlType::Label;
  523. label.text = "Machine";
  524. project.hmiPages.front().controls.push_back(label);
  525. require(project.validate(defaultProjectLimitSettings()), "an unbound label must be a valid static control");
  526. project.hmiPages.front().controls.back().binding =
  527. RegisterAddress{RegisterArea::M, 10};
  528. require(!project.validate(defaultProjectLimitSettings()), "labels must reject register bindings");
  529. project = makeValidProject();
  530. project.hmiPages.push_back(settings);
  531. HmiControl jump;
  532. jump.id = "settings-jump";
  533. jump.type = HmiControlType::PageJump;
  534. jump.text = "Settings";
  535. jump.pageJump = HmiPageJumpConfig{settings.id};
  536. project.hmiPages.front().controls.push_back(jump);
  537. require(project.validate(defaultProjectLimitSettings()) && project.validateForRunning(defaultProjectLimitSettings()),
  538. "a page jump must resolve its target by stable page id");
  539. project.hmiPages.front().controls.back().pageJump->targetPageId = "missing";
  540. require(!project.validate(defaultProjectLimitSettings()), "a page jump must reject a missing target page");
  541. project = makeValidProject();
  542. project.initialHmiPageId = "missing";
  543. require(!project.validate(defaultProjectLimitSettings()), "the initial HMI page id must resolve to a page");
  544. project = makeValidProject();
  545. HmiPage duplicate_name = settings;
  546. duplicate_name.name = project.hmiPages.front().name;
  547. project.hmiPages.push_back(duplicate_name);
  548. require(!project.validate(defaultProjectLimitSettings()), "HMI page names must be unique");
  549. project = makeValidProject();
  550. ControlLogic disabled_draft;
  551. disabled_draft.id = "draft-logic";
  552. disabled_draft.name = "Draft logic";
  553. disabled_draft.enabled = false;
  554. LadderRung draft_rung;
  555. draft_rung.id = "rung-1";
  556. draft_rung.name = "Draft network";
  557. disabled_draft.rungs.push_back(std::move(draft_rung));
  558. project.controlLogics.push_back(disabled_draft);
  559. require(project.validateForRunning(defaultProjectLimitSettings()),
  560. "a disabled draft logic must not block offline running");
  561. project.controlLogics.back().name = project.controlLogics.front().name;
  562. require(!project.validate(defaultProjectLimitSettings()), "control logic names must be unique");
  563. project = makeValidProject();
  564. project.hmiPages.front().controls.front().type =
  565. static_cast<HmiControlType>(99);
  566. project.hmiPages.front().controls.front().binding.reset();
  567. require(!project.validate(defaultProjectLimitSettings()), "unknown HMI control types must be rejected");
  568. }
  569. void testQuantityBoundaries()
  570. {
  571. Project project = makeValidProject();
  572. for (std::size_t index = 1U; index < ProjectLimits::kMaximumHmiPages; ++index)
  573. {
  574. project.hmiPages.push_back({
  575. "page-" + std::to_string(index),
  576. "Page " + std::to_string(index),
  577. 800,
  578. 400,
  579. {}});
  580. }
  581. require(project.validate(defaultProjectLimitSettings()), "an HMI page count at the configured limit must be accepted");
  582. project.hmiPages.push_back({"page-over", "Page over", 800, 400, {}});
  583. require(!project.validate(defaultProjectLimitSettings()), "an HMI page count of 129 must be rejected");
  584. project = makeValidProject();
  585. project.hmiPages.clear();
  586. project.initialHmiPageId.clear();
  587. for (std::size_t page_index = 0U; page_index < 17U; ++page_index)
  588. {
  589. HmiPage page{
  590. "bulk-page-" + std::to_string(page_index),
  591. "Bulk page " + std::to_string(page_index),
  592. 800,
  593. 400,
  594. {}};
  595. for (std::size_t control_index = 0U;
  596. control_index < ProjectLimits::kMaximumHmiControlsPerPage;
  597. ++control_index)
  598. {
  599. HmiControl label;
  600. label.id = "label-" + std::to_string(control_index);
  601. label.type = HmiControlType::Label;
  602. label.bounds = {0, 0, 1, 1};
  603. label.text = "label";
  604. page.controls.push_back(std::move(label));
  605. }
  606. project.hmiPages.push_back(std::move(page));
  607. }
  608. project.initialHmiPageId = project.hmiPages.front().id;
  609. require(!project.validate(defaultProjectLimitSettings()),
  610. "an HMI control count over the project limit must be rejected");
  611. project = makeValidProject();
  612. project.hmiPages.front().controls.clear();
  613. for (std::size_t index = 0U;
  614. index < ProjectLimits::kMaximumHmiControlsPerPage;
  615. ++index)
  616. {
  617. HmiControl label;
  618. label.id = "label-" + std::to_string(index);
  619. label.type = HmiControlType::Label;
  620. label.bounds = {0, 0, 1, 1};
  621. label.text = "label";
  622. project.hmiPages.front().controls.push_back(std::move(label));
  623. }
  624. require(project.validate(defaultProjectLimitSettings()), "a page control count at the configured limit must be accepted");
  625. HmiControl extra_label;
  626. extra_label.id = "label-over";
  627. extra_label.type = HmiControlType::Label;
  628. extra_label.bounds = {0, 0, 1, 1};
  629. extra_label.text = "label";
  630. project.hmiPages.front().controls.push_back(std::move(extra_label));
  631. require(!project.validate(defaultProjectLimitSettings()), "a page control count of 513 must be rejected");
  632. project = makeValidProject();
  633. project.controlLogics.clear();
  634. for (std::size_t logic_index = 0U; logic_index < 9U; ++logic_index)
  635. {
  636. ControlLogic logic{
  637. "bulk-logic-" + std::to_string(logic_index),
  638. "Bulk logic " + std::to_string(logic_index),
  639. {},
  640. true};
  641. for (std::size_t rung_index = 0U;
  642. rung_index < ProjectLimits::kMaximumRungsPerLogic;
  643. ++rung_index)
  644. {
  645. logic.rungs.push_back({
  646. "rung-" + std::to_string(rung_index),
  647. "Rung " + std::to_string(rung_index),
  648. {},
  649. std::nullopt,
  650. {}});
  651. }
  652. project.controlLogics.push_back(std::move(logic));
  653. }
  654. require(!project.validate(defaultProjectLimitSettings()),
  655. "a ladder rung count over the project limit must be rejected");
  656. project = makeValidProject();
  657. project.hmiPages.front().width = ProjectLimits::kMaximumHmiPageWidth;
  658. project.hmiPages.front().height = ProjectLimits::kMaximumHmiPageHeight;
  659. require(project.validate(defaultProjectLimitSettings()), "an HMI page size of 1600 by 800 must be accepted");
  660. project.hmiPages.front().width = ProjectLimits::kMaximumHmiPageWidth + 1;
  661. require(!project.validate(defaultProjectLimitSettings()), "an HMI page width of 1601 must be rejected");
  662. project.hmiPages.front().width = ProjectLimits::kMinimumHmiPageWidth - 1;
  663. require(!project.validate(defaultProjectLimitSettings()), "an HMI page width of 319 must be rejected");
  664. project.hmiPages.front().width = ProjectLimits::kMaximumHmiPageWidth;
  665. project.hmiPages.front().height = ProjectLimits::kMinimumHmiPageHeight - 1;
  666. require(!project.validate(defaultProjectLimitSettings()), "an HMI page height of 199 must be rejected");
  667. project = makeValidProject();
  668. project.controlLogics.front().rungs.front().cells.pop_back();
  669. require(!project.validate(defaultProjectLimitSettings()),
  670. "a ladder row with fewer than ten cells must be rejected");
  671. }
  672. void testLogicNodeConfigurationBoundaries()
  673. {
  674. // 触点只能绑定 M 区,数值比较只能绑定 D 区
  675. LogicNode contact;
  676. contact.id = "contact";
  677. contact.config = ContactNodeConfig{
  678. RegisterAddress{RegisterArea::M, 0},
  679. ContactMode::NormallyOpen};
  680. require(contact.validate(), "contact node bound to M address must be valid");
  681. contact.config = ContactNodeConfig{
  682. RegisterAddress{RegisterArea::D, 0},
  683. ContactMode::NormallyOpen};
  684. require(!contact.validate(), "contact node bound to D address must be rejected");
  685. LogicNode comparison;
  686. comparison.id = "comparison";
  687. comparison.config = CompareNodeConfig{
  688. RegisterAddress{RegisterArea::D, 0},
  689. ComparisonOperator::GreaterThan,
  690. static_cast<std::int16_t>(100)};
  691. require(comparison.validate(), "comparison node bound to D address must be valid");
  692. }
  693. void testEdgeAndCommentBoundaries()
  694. {
  695. LogicNode edge;
  696. edge.id = "edge";
  697. edge.config = EdgeContactNodeConfig{
  698. RegisterAddress{RegisterArea::M, 0}, EdgeMode::Rising};
  699. require(edge.validate(), "a valid rising edge contact must pass validation");
  700. RegisterComment comment{RegisterAddress{RegisterArea::M, 0}, "启动按钮"};
  701. require(comment.validate(), "a nonblank register comment must be valid");
  702. comment.text.assign(ProjectLimits::kMaximumRegisterCommentBytes, 'a');
  703. require(comment.validate(), "a register comment at the byte limit must be valid");
  704. comment.text.push_back('a');
  705. require(!comment.validate(), "a register comment above the byte limit must fail");
  706. comment.text = "启动\n按钮";
  707. require(!comment.validate(), "a multiline register comment must be rejected");
  708. comment.text = "启动\r按钮";
  709. require(!comment.validate(), "a register comment containing CR must be rejected");
  710. comment.text = " \t";
  711. require(!comment.validate(), "a blank register comment must be rejected");
  712. LadderRung comment_rung;
  713. comment_rung.id = "comment-rung";
  714. comment_rung.name = "Comment rung";
  715. comment_rung.comment.assign(ProjectLimits::kMaximumRungCommentBytes, 'a');
  716. require(comment_rung.validateStructure(), "a rung comment at the byte limit must be valid");
  717. comment_rung.comment.push_back('a');
  718. require(!comment_rung.validateStructure(), "a rung comment above the byte limit must fail");
  719. comment_rung.comment = "第一行\n第二行";
  720. require(!comment_rung.validateStructure(), "a multiline rung comment must be rejected");
  721. comment_rung.comment = "第一行\r第二行";
  722. require(!comment_rung.validateStructure(), "a rung comment containing CR must be rejected");
  723. ControlLogic commented_logic;
  724. commented_logic.id = "commented-logic";
  725. commented_logic.name = "Commented logic";
  726. LadderRung head;
  727. head.id = "head";
  728. head.name = "Head";
  729. head.comment = "Network comment";
  730. LadderRung branch;
  731. branch.id = "branch";
  732. branch.name = "Branch";
  733. branch.comment = "Hidden branch comment";
  734. commented_logic.rungs = {head, branch};
  735. commented_logic.verticalConnections = {
  736. {"comment-edge", "head", "branch", 0}};
  737. require(
  738. commented_logic.networkHeadIndex(1U) == 0U
  739. && !commented_logic.validateStructure(),
  740. "a connected branch row must not persist a hidden network comment");
  741. commented_logic.rungs[1].comment.clear();
  742. require(commented_logic.validateStructure(),
  743. "a connected network must be valid when only its head stores the comment");
  744. Project project = makeValidProject();
  745. project.registerComments = {
  746. {RegisterAddress{RegisterArea::M, 0}, "启动按钮"},
  747. {RegisterAddress{RegisterArea::M, 0}, "重复地址"}};
  748. require(!project.validate(defaultProjectLimitSettings()), "duplicate register comments must be rejected");
  749. }
  750. void testDataInstructionBoundaries()
  751. {
  752. LogicNode move;
  753. move.id = "move";
  754. move.config = MoveNodeConfig{
  755. WordOperand{
  756. WordOperandKind::Constant,
  757. RegisterAddress{RegisterArea::D, 0},
  758. -100},
  759. RegisterAddress{RegisterArea::D, 20}};
  760. require(move.validate() && move.isOutput(),
  761. "MOVE with a constant source and D destination must be a valid output");
  762. LogicNode add;
  763. add.id = "add";
  764. add.config = ArithmeticNodeConfig{
  765. ArithmeticOperation::Add,
  766. WordOperand{
  767. WordOperandKind::Register,
  768. RegisterAddress{RegisterArea::D, 20},
  769. 0},
  770. WordOperand{
  771. WordOperandKind::Constant,
  772. RegisterAddress{RegisterArea::D, 0},
  773. 1},
  774. RegisterAddress{RegisterArea::D, 20}};
  775. require(add.validate() && add.isOutput(),
  776. "ADD must allow the same D register as source and destination");
  777. }
  778. void testLadderLogicBoundaries()
  779. {
  780. ControlLogic logic;
  781. logic.id = "grid-logic";
  782. logic.name = "Grid logic";
  783. LadderRung upper;
  784. upper.id = "rung-1";
  785. upper.name = "Row 1";
  786. LadderRung lower;
  787. lower.id = "rung-2";
  788. lower.name = "Row 2";
  789. for (int column = 0;
  790. column < ProjectLimits::kMaximumConditionColumns;
  791. ++column)
  792. {
  793. upper.cells.push_back({
  794. "upper-cell-" + std::to_string(column),
  795. LadderCellKind::Wire,
  796. std::nullopt});
  797. lower.cells.push_back({
  798. "lower-cell-" + std::to_string(column),
  799. LadderCellKind::Gap,
  800. std::nullopt});
  801. }
  802. upper.cells[0].kind = LadderCellKind::Node;
  803. upper.cells[0].node = LogicNode{
  804. "start",
  805. ContactNodeConfig{
  806. RegisterAddress{RegisterArea::M, 0},
  807. ContactMode::NormallyOpen},
  808. true};
  809. upper.output = LogicNode{
  810. "run-coil",
  811. CoilNodeConfig{
  812. RegisterAddress{RegisterArea::M, 1}, CoilMode::Normal},
  813. true};
  814. logic.rungs = {upper, lower};
  815. logic.verticalConnections = {
  816. {"vertical-left", "rung-1", "rung-2", 0},
  817. {"vertical-right", "rung-1", "rung-2", 1}};
  818. require(logic.validate(defaultProjectLimitSettings()) && logic.validateForRunning(defaultProjectLimitSettings()),
  819. "a ten-cell grid with adjacent vertical edges must be valid");
  820. logic.rungs.front().cells[5].kind = LadderCellKind::Gap;
  821. std::string connectivity_error;
  822. require(
  823. logic.validate(defaultProjectLimitSettings()) && !logic.validateForRunning(&connectivity_error)
  824. && connectivity_error.find("第 1 行") != std::string::npos
  825. && connectivity_error.find("第 6 列") != std::string::npos,
  826. "a disconnected output must report its visual row and break column");
  827. logic.rungs.front() = upper;
  828. logic.rungs.front().cells[5].kind = LadderCellKind::Gap;
  829. for (LadderCell &cell : logic.rungs.back().cells)
  830. {
  831. cell.kind = LadderCellKind::Wire;
  832. cell.node.reset();
  833. }
  834. logic.verticalConnections = {
  835. {"vertical-left", "rung-1", "rung-2", 0},
  836. {"vertical-bypass", "rung-1", "rung-2", 6}};
  837. require(
  838. logic.validateForRunning(defaultProjectLimitSettings()),
  839. "a vertical branch that bypasses a gap must keep the output reachable");
  840. logic.rungs = {upper, lower};
  841. logic.verticalConnections = {
  842. {"vertical-left", "rung-1", "rung-2", 0},
  843. {"vertical-right", "rung-1", "rung-2", 1}};
  844. logic.rungs.front().cells.front().node = LogicNode{
  845. "invalid-coil",
  846. CoilNodeConfig{
  847. RegisterAddress{RegisterArea::M, 2}, CoilMode::Normal},
  848. true};
  849. require(!logic.validate(defaultProjectLimitSettings()), "a condition cell must reject output nodes");
  850. logic.rungs.front() = upper;
  851. logic.rungs.front().output = LogicNode{
  852. "invalid-contact",
  853. ContactNodeConfig{
  854. RegisterAddress{RegisterArea::M, 2}, ContactMode::NormallyOpen},
  855. true};
  856. require(!logic.validate(defaultProjectLimitSettings()), "the output slot must reject condition nodes");
  857. logic.rungs.front() = upper;
  858. logic.rungs.front().output.reset();
  859. require(logic.validate(defaultProjectLimitSettings()) && logic.validateForRunning(defaultProjectLimitSettings()),
  860. "a row without an output may act as a connected branch");
  861. logic.rungs.front() = upper;
  862. logic.rungs.front().cells[1].id = logic.rungs.front().cells[0].id;
  863. require(!logic.validate(defaultProjectLimitSettings()), "cell ids must be unique within a logic");
  864. logic.rungs.front() = upper;
  865. logic.verticalConnections.front().lowerRungId = "missing-rung";
  866. require(!logic.validate(defaultProjectLimitSettings()), "vertical edges must reference adjacent rows");
  867. logic.verticalConnections = {
  868. {"vertical-left", "rung-1", "rung-2", 0},
  869. {"vertical-copy", "rung-1", "rung-2", 0}};
  870. require(!logic.validate(defaultProjectLimitSettings()),
  871. "one row boundary must not contain duplicate vertical edges");
  872. }
  873. void testModelsValidateBindingsAndIdentifiers()
  874. {
  875. // 聚合验证必须拒绝错误绑定、重复标识和越界控件
  876. Project project = makeValidProject();
  877. require(project.validate(defaultProjectLimitSettings()), "valid project model must pass validation");
  878. project.hmiPages.front().controls.front().binding =
  879. RegisterAddress{RegisterArea::D, 0};
  880. require(!project.validate(defaultProjectLimitSettings()), "button bound to D area must be rejected");
  881. project = makeValidProject();
  882. project.hmiPages.push_back(project.hmiPages.front());
  883. require(!project.validate(defaultProjectLimitSettings()), "duplicate HMI page id must be rejected");
  884. project = makeValidProject();
  885. project.hmiPages.front().controls.front().bounds.x = -1;
  886. require(!project.validate(defaultProjectLimitSettings()), "controls outside the page must be rejected");
  887. project = makeValidProject();
  888. project.hmiPages.front().controls.front().bounds.width = 801;
  889. require(!project.validate(defaultProjectLimitSettings()), "controls wider than the page must be rejected");
  890. project = makeValidProject();
  891. project.hmiPages.front().controls.front().properties.emplace("", "value");
  892. require(!project.validate(defaultProjectLimitSettings()), "empty HMI property names must be rejected");
  893. project = makeValidProject();
  894. project.hmiPages.front().controls.front().binding.reset();
  895. require(project.validate(defaultProjectLimitSettings()), "unbound HMI control must be accepted in a draft");
  896. require(!project.validateForRunning(defaultProjectLimitSettings()),
  897. "unbound HMI control must block runtime validation");
  898. project = makeValidProject();
  899. project.controlLogics.front().rungs.front().output->configured = false;
  900. require(project.validate(defaultProjectLimitSettings()), "unconfigured ladder node must be accepted in a draft");
  901. require(!project.validateForRunning(defaultProjectLimitSettings()),
  902. "unconfigured ladder node must block runtime validation");
  903. }
  904. void testRuntimeStateBoundaries()
  905. {
  906. // 运行模式测试覆盖离线和真机的互斥及 PLC 首读前置条件
  907. RuntimeState state;
  908. require(state.policy().allowsProjectEditing, "editing mode must allow project editing");
  909. require(state.enterOfflineRunning().succeeded, "editing may enter offline running");
  910. require(state.policy().usesVirtualRegisters, "offline mode must use virtual registers");
  911. require(state.policy().runsLogicExecutor, "offline mode must run logic executor");
  912. require(state.enterOnlineRunning(true).error
  913. == ModeTransitionError::MustReturnToEditing,
  914. "offline mode must not directly enter online mode");
  915. require(state.enterEditing().succeeded, "offline mode may return to editing");
  916. require(state.enterOnlineRunning(false).error
  917. == ModeTransitionError::InitialPlcReadRequired,
  918. "online mode must require an initial PLC read");
  919. require(state.enterOnlineRunning(true).succeeded,
  920. "editing may enter online mode after initial PLC read");
  921. require(state.policy().runsLogicExecutor,
  922. "online mode must run the local read-only trace executor");
  923. require(state.policy().usesPlcRegisters, "online mode must use PLC registers");
  924. }
  925. void testRuntimeConfiguredProjectLimits()
  926. {
  927. ProjectLimitSettings limits;
  928. std::string error;
  929. Project project = makeValidProject();
  930. HmiPage second_page = project.hmiPages.front();
  931. second_page.id = "second-page";
  932. second_page.name = "Second page";
  933. project.hmiPages.push_back(second_page);
  934. limits.maximumHmiPages = 1U;
  935. require(!project.validate(limits, &error)
  936. && error.find("当前配置上限为 1") != std::string::npos,
  937. "runtime page limits must be enforced by aggregate validation");
  938. project = makeValidProject();
  939. HmiControl second_control = project.hmiPages.front().controls.front();
  940. second_control.id = "second-control";
  941. project.hmiPages.front().controls.push_back(second_control);
  942. limits = {};
  943. limits.maximumHmiControlsPerPage = 1U;
  944. require(!project.validate(limits, &error),
  945. "runtime per-page control limits must be enforced");
  946. project = makeValidProject();
  947. project.alarmDefinitions.push_back({});
  948. limits = {};
  949. limits.maximumAlarmDefinitions = 0U;
  950. require(!project.validate(limits, &error),
  951. "runtime alarm limits must be enforced before child validation");
  952. project = makeValidProject();
  953. ControlLogic second_logic = project.controlLogics.front();
  954. second_logic.id = "second-logic";
  955. second_logic.name = "Second logic";
  956. second_logic.rungs.clear();
  957. project.controlLogics.push_back(second_logic);
  958. limits = {};
  959. limits.maximumControlLogics = 1U;
  960. require(!project.validate(limits, &error),
  961. "runtime control-logic limits must be enforced");
  962. project = makeValidProject();
  963. limits = {};
  964. limits.maximumRungsPerLogic = 0U;
  965. require(!project.validate(limits, &error),
  966. "runtime per-logic rung limits must be enforced");
  967. }
  968. } // namespace
  969. int main()
  970. {
  971. try
  972. {
  973. // 每个测试函数独立覆盖一个领域边界,首个异常即终止测试进程
  974. testRegisterAddressBoundaries();
  975. testRegisterAddressParsing();
  976. testRegisterRepositorySeparatesAreas();
  977. testMultiWordCodecsAndBlockAccess();
  978. testHmiControlRegistryCompleteness();
  979. testStatusTextDomainRules();
  980. testMultiWordHmiBoundaries();
  981. testHmiAppearancePropertyBoundaries();
  982. testLogicNodeConfigurationBoundaries();
  983. testEdgeAndCommentBoundaries();
  984. testDataInstructionBoundaries();
  985. testLadderLogicBoundaries();
  986. testModelsValidateBindingsAndIdentifiers();
  987. testMultiPageAndLogicDomainRules();
  988. testQuantityBoundaries();
  989. testRuntimeConfiguredProjectLimits();
  990. testRuntimeStateBoundaries();
  991. }
  992. catch (const std::exception &error)
  993. {
  994. std::cerr << "domain tests failed: " << error.what() << '\n';
  995. return 1;
  996. }
  997. std::cout << "domain tests passed\n";
  998. return 0;
  999. }