|
2 | 2 | // Use of this source code is governed by the MIT license that can be found in
|
3 | 3 | // the LICENSE file.
|
4 | 4 | #include <gtest/gtest.h> // for Test, TestInfo (ptr only), EXPECT_EQ, Message, TEST, TestPartResult
|
5 |
| -#include <cstddef> // for size_t |
6 |
| -#include <string> // for allocator, basic_string, string |
7 |
| -#include <vector> // for vector |
| 5 | +#include <array> // for array |
| 6 | +#include <cstddef> // for size_t |
| 7 | +#include <stack> // for stack |
| 8 | +#include <string> // for allocator, basic_string, string |
| 9 | +#include <unordered_set> // for unordered_set |
| 10 | +#include <vector> // for vector |
8 | 11 |
|
9 | 12 | #include "ftxui/dom/elements.hpp" // for text, operator|, Element, flex_grow, flex_shrink, hbox
|
10 | 13 | #include "ftxui/dom/node.hpp" // for Render
|
@@ -358,5 +361,39 @@ TEST(HBoxTest, FlexGrow_NoFlex_FlewShrink) {
|
358 | 361 | }
|
359 | 362 | }
|
360 | 363 |
|
| 364 | +TEST(HBoxTest, FromElementsContainer) { |
| 365 | + Elements elements_vector{text("0"), text("1")}; |
| 366 | + |
| 367 | + std::array<Element, 2> elements_array{text("0"), text("1")}; |
| 368 | + |
| 369 | + std::deque<Element> elements_deque{text("0"), text("1")}; |
| 370 | + |
| 371 | + std::stack<Element> elements_stack; |
| 372 | + elements_stack.push(text("1")); |
| 373 | + elements_stack.push(text("0")); |
| 374 | + |
| 375 | + std::queue<Element> elements_queue; |
| 376 | + elements_queue.emplace(text("0")); |
| 377 | + elements_queue.emplace(text("1")); |
| 378 | + |
| 379 | + const std::vector<Element> collection_hboxes{ |
| 380 | + hbox(std::move(elements_vector)), hbox(std::move(elements_array)), |
| 381 | + hbox(std::move(elements_stack)), hbox(std::move(elements_deque)), |
| 382 | + hbox(std::move(elements_queue)), |
| 383 | + }; |
| 384 | + |
| 385 | + for (const Element& collection_hbox : collection_hboxes) { |
| 386 | + Screen screen(2, 1); |
| 387 | + Render(screen, collection_hbox); |
| 388 | + EXPECT_EQ("01", screen.ToString()); |
| 389 | + } |
| 390 | + |
| 391 | + // Exception: unordered set, which has no guaranteed order. |
| 392 | + std::unordered_set<Element> elements_set{text("0"), text("0")}; |
| 393 | + Screen screen(2, 1); |
| 394 | + Render(screen, hbox(elements_set)); |
| 395 | + EXPECT_EQ("00", screen.ToString()); |
| 396 | +}; |
| 397 | + |
361 | 398 | } // namespace ftxui
|
362 | 399 | // NOLINTEND
|
0 commit comments