* Test if a NWidgetTree is properly closed, meaning the number of container-type parts matches the number of * EndContainer() parts. * @param nwid_parts Span of nested widget parts. * @return True iff nested tree is properly closed. */
| 66 | * @return True iff nested tree is properly closed. |
| 67 | */ |
| 68 | static bool IsNWidgetTreeClosed(std::span<const NWidgetPart> nwid_parts) |
| 69 | { |
| 70 | int depth = 0; |
| 71 | for (const auto nwid : nwid_parts) { |
| 72 | if (IsContainerWidgetType(nwid.type)) ++depth; |
| 73 | if (nwid.type == WPT_ENDCONTAINER) --depth; |
| 74 | } |
| 75 | return depth == 0; |
| 76 | } |
| 77 | |
| 78 | TEST_CASE("WindowDesc - NWidgetParts properly closed") |
| 79 | { |
no test coverage detected