menu: unit test with section #179

pull/319/head
nick black 4 years ago
parent 0977fa0d56
commit 5cf1bba5f5
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -2210,13 +2210,15 @@ API void ncselector_destroy(struct ncselector* n, char** item);
// a screen resize, menus will be automatically moved/resized. Elements can be
// dynamically enabled or disabled at all levels (menu, section, and item),
struct ncmenu_item {
char* desc; // utf-8 menu item, NULL for horizontal separator
ncinput shortcut; // shortcut, all should be distinct
};
struct ncmenu_section {
char* name; // utf-8 c string
struct ncmenu_item {
char* desc; // utf-8 menu item, NULL for horizontal separator
ncinput shortcut; // shortcut, all should be distinct
}* items;
int itemcount;
struct ncmenu_item* items;
int xoff; // used only in library copy, ignored in request
int bodycols; // used only in library copy, ignored in request
int itemselected; // used only in library copy, ignored in request

@ -34,6 +34,23 @@ TEST_CASE("MenuTest") {
ncmenu_destroy(ncm);
}
SUBCASE("MenuOneSection") {
struct ncmenu_item file_items[] = {
{ .desc = strdup("I would like a new file"), .shortcut = {}, },
};
struct ncmenu_section sections[] = {
{ .name = strdup("File"), .itemcount = sizeof(file_items) / sizeof(*file_items), .items = file_items,
.xoff = -1, .bodycols = -1, .itemselected = -1, },
};
struct ncmenu_options opts{};
opts.sections = sections;
opts.sectioncount = sizeof(sections) / sizeof(*sections);
struct ncmenu* ncm = ncmenu_create(nc_, &opts);
REQUIRE(nullptr != ncm);
CHECK(0 == notcurses_render(nc_));
ncmenu_destroy(ncm);
}
CHECK(0 == notcurses_stop(nc_));
CHECK(0 == fclose(outfp_));
}

Loading…
Cancel
Save