From 4a9ce6e2555dfaf9155fa279f25667350377f688 Mon Sep 17 00:00:00 2001 From: Daniil Rozanov Date: Sat, 15 Mar 2025 18:03:23 +0400 Subject: feat: chtype wrap --- tests/multiflags/multiflags.cpp | 64 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/multiflags/multiflags.cpp (limited to 'tests/multiflags') diff --git a/tests/multiflags/multiflags.cpp b/tests/multiflags/multiflags.cpp new file mode 100644 index 0000000..e689892 --- /dev/null +++ b/tests/multiflags/multiflags.cpp @@ -0,0 +1,64 @@ +#include +#define NCURSES_CPP_FLAGS_MASK_TYPE_AS_PUBLIC + +#include +#include +#include +#include + +using namespace ncurses; + +template <> struct is_applyable : std::true_type {}; + +using full_attrs = multiflags; + +int main(int argc, char *argv[]) { + { + full_attrs attr; + assert(attr.value_ == 0); + + attr = attr::blink; + assert(attr.value_ == A_BLINK); + + attr = color_pair(22); + assert(attr.value_ == COLOR_PAIR(22)); + + attr = attr::bold | attr::italic | attr::top; + assert(attr.value_ == (A_TOP | A_ITALIC | A_BOLD)); + } + { + full_attrs attr = attr::color | color_pair(10); + assert(attr.value_ == (A_COLOR | COLOR_PAIR(10))); + } + { + full_attrs attr = color_pair(10) | attr::color; + assert(attr.value_ == (A_COLOR | COLOR_PAIR(10))); + } + { + full_attrs attr = color_pair(11) | attr::altcharset | attr::dim; + assert(attr.value_ == (A_ALTCHARSET | A_DIM | COLOR_PAIR(11))); + } + { + full_attrs attr = attr::top | color_pair(30); + assert(attr != color_pair(1)); + assert(attr != attr::chartext); + assert(attr != (attr::bold | attr::dim)); + assert(attr != (attr::bold | attr::dim | color_pair(1))); + assert(attr == (full_attrs(attr::top) | color_pair(30))); + } + { + full_attrs attr; + // attr_flags to full_attrs + attr = attr_flags(attr::top | attr::dim | attr::bold); + // color + attr to full_attrs + attr to full_attrs + attr = color_pair(1) | attr::top | attr::bold; + + // color + attr_flags to full_attrs + attr = color_pair(2) | (attr::top & attr::bold); + + // attr_flags + color to full_attrs + attr = (attr::top & attr::bold) | color_pair(2); + } + + return 0; +} -- cgit v1.2.3