-
-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dropdown: Fix title not updated. (#851)
- Loading branch information
1 parent
af49b57
commit ecacb22
Showing
4 changed files
with
160 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |