#include #include #include #include using uc = unsigned char; void test_color(int index, uc r, uc g, uc b) { short r_, g_, b_; assert(color_content(static_cast(index), &r_, &g_, &b_) == OK); assert(static_cast(ncurses::curses_to_rgb(r_) == r)); assert(static_cast(ncurses::curses_to_rgb(g_) == g)); assert(static_cast(ncurses::curses_to_rgb(b_) == b)); } void test_color_pair(int index, int a_index, int a_r, int a_g, int a_b, int b_index, int b_r, int b_g, int b_b) { short a_index_, a_r_, a_g_, a_b_, b_index_, b_r_, b_g_, b_b_; assert(pair_content(index, &a_index_, &b_index_) == OK); assert(a_index_ == a_index && b_index_ == b_index); test_color(a_index, a_r, a_g, a_b); test_color(b_index, b_r, b_g, b_b); } int main(int argc, char *argv[]) { initscr(); if (has_colors() == FALSE) { endwin(); std::exit(1); } start_color(); uc i = 0; while (1) { assert(i == ncurses::curses_to_rgb(ncurses::rgb_to_curses(i))); if (i == 255) break; i++; } // TODO: what if user wants to use color/pair as rvalue, or instantiate it as // a variable? Problem is current realization only accepts api as above. // Should I forbid anything else or somehow extend functionality? endwin(); return 0; }