mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-18 00:48:09 +08:00
Dropdown: Fix title not updated. (#851)
A bug was introduced by: https://github.com/ArthurSonzogni/FTXUI/pull/826 The checkbox label wasn't updated. Bug:https://github.com/ArthurSonzogni/FTXUI/issues/861
This commit is contained in:
63
src/ftxui/util/ref_test.cpp
Normal file
63
src/ftxui/util/ref_test.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#include "ftxui/util/ref.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "ftxui/component/component.hpp"
|
||||
|
||||
namespace ftxui {
|
||||
namespace {
|
||||
class Adapter : public ConstStringListRef::Adapter {
|
||||
public:
|
||||
Adapter(std::vector<std::string>& entries) : entries(entries) {}
|
||||
size_t size() const override { return entries.size() * 2; }
|
||||
std::string operator[](size_t index) const override {
|
||||
return entries[index / 2];
|
||||
}
|
||||
std::vector<std::string>& entries;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
TEST(ConstStringListRef, Copy) {
|
||||
std::vector<std::string> entries = {
|
||||
"entry 1",
|
||||
"entry 2",
|
||||
"entry 3",
|
||||
};
|
||||
int selected = 0;
|
||||
auto menu = Menu(entries, &selected);
|
||||
}
|
||||
|
||||
TEST(ConstStringListRef, Ref) {
|
||||
std::vector<std::string> entries = {
|
||||
"entry 1",
|
||||
"entry 2",
|
||||
"entry 3",
|
||||
};
|
||||
int selected = 0;
|
||||
auto menu = Menu(&entries, &selected);
|
||||
}
|
||||
|
||||
TEST(ConstStringListRef, Adapter) {
|
||||
std::vector<std::string> entries = {
|
||||
"entry 1",
|
||||
"entry 2",
|
||||
"entry 3",
|
||||
};
|
||||
|
||||
int selected = 0;
|
||||
Adapter a(entries);
|
||||
auto menu = Menu(&a, &selected);
|
||||
}
|
||||
|
||||
TEST(ConstStringListRef, UniquePtrAdapter) {
|
||||
std::vector<std::string> entries = {
|
||||
"entry 1",
|
||||
"entry 2",
|
||||
"entry 3",
|
||||
};
|
||||
|
||||
int selected = 0;
|
||||
auto a = std::make_unique<Adapter>(entries);
|
||||
auto menu = Menu(std::move(a), &selected);
|
||||
}
|
||||
|
||||
} // namespace ftxui
|
Reference in New Issue
Block a user