summaryrefslogtreecommitdiff
path: root/tests/multiflags
diff options
context:
space:
mode:
Diffstat (limited to 'tests/multiflags')
-rw-r--r--tests/multiflags/multiflags.cpp64
1 files changed, 64 insertions, 0 deletions
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 <ncurses.h>
+#define NCURSES_CPP_FLAGS_MASK_TYPE_AS_PUBLIC
+
+#include <cassert>
+#include <ncurses/char_attributes.hpp>
+#include <ncurses/colors.hpp>
+#include <ncurses/utils/multiflags.hpp>
+
+using namespace ncurses;
+
+template <> struct is_applyable<color_pair, attr> : std::true_type {};
+
+using full_attrs = multiflags<attr, color_pair>;
+
+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;
+}