test: move all module tests to the test/ directory
This commit is contained in:
79
test/term/printing.c
Normal file
79
test/term/printing.c
Normal file
@@ -0,0 +1,79 @@
|
||||
#include <blue/term/tty.h>
|
||||
#include <blue/term/print.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define F_GREEN "[green]"
|
||||
#define F_YELLOW "[yellow]"
|
||||
#define F_RESET "[reset]"
|
||||
|
||||
static const char *text = F_YELLOW
|
||||
"But I must " F_GREEN "explain " F_YELLOW "to you " F_GREEN
|
||||
"how all this " F_YELLOW "mistaken idea of" F_RESET
|
||||
" denouncing pleasure " F_GREEN "and praising pain was born " F_YELLOW
|
||||
"and I will give you " F_RESET "a complete account of " F_YELLOW
|
||||
"the system, and " F_RESET
|
||||
"expound the actual teachings of the great explorer of the truth, the "
|
||||
"master-builder of human happiness.\n"
|
||||
"No one rejects, dislikes, or avoids pleasure itself, because it is "
|
||||
"pleasure, but because those who do not know how to pursue pleasure "
|
||||
"rationally encounter consequences that are extremely painful. Nor "
|
||||
"again is there anyone who loves or pursues or desires to obtain pain "
|
||||
"of itself, because it is pain, but because occasionally circumstances "
|
||||
"occur in which toil and pain can procure him some great pleasure.\n"
|
||||
"To take a trivial example, which of us ever undertakes laborious "
|
||||
"physical exercise, except to obtain some advantage from it? But who "
|
||||
"has any right to find fault with a man who chooses to enjoy a "
|
||||
"pleasure that has no annoying consequences, or one who avoids a pain "
|
||||
"that produces no resultant pleasure? On the other hand, we denounce "
|
||||
"with righteous indignation and dislike men who are so beguiled and "
|
||||
"demoralized by the charms of pleasure of the moment, so blinded by "
|
||||
"desire, that they cannot foresee.";
|
||||
|
||||
static const char *text2
|
||||
= "But I must explain to you how all this mistaken idea of denouncing "
|
||||
"pleasure and praising pain was born and I will give you a complete "
|
||||
"account of the system, and expound the actual teachings of the "
|
||||
"great explorer of the truth, the master-builder of human "
|
||||
"happiness.\n"
|
||||
"No one rejects, dislikes, or avoids pleasure itself, because it is "
|
||||
"pleasure, but because those who do not know how to pursue pleasure "
|
||||
"rationally encounter consequences that are extremely painful. Nor "
|
||||
"again is there anyone who loves or pursues or desires to obtain "
|
||||
"pain of itself, because it is pain, but because occasionally "
|
||||
"circumstances occur in which toil and pain can procure him some "
|
||||
"great pleasure.\n"
|
||||
"To take a trivial example, which of us ever undertakes laborious "
|
||||
"physical exercise, except to obtain some advantage from it? But who "
|
||||
"has any right to find fault with a man who chooses to enjoy a "
|
||||
"pleasure that has no annoying consequences, or one who avoids a "
|
||||
"pain that produces no resultant pleasure? On the other hand, we "
|
||||
"denounce with righteous indignation and dislike men who are so "
|
||||
"beguiled and demoralized by the charms of pleasure of the moment, "
|
||||
"so blinded by desire, that they cannot foresee.";
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const char *s = "[magenta,uline]Hello, [bright_magenta]world![reset]";
|
||||
b_puts(s);
|
||||
b_putc('\n');
|
||||
|
||||
b_string *str = b_string_create_from_cstr(s);
|
||||
size_t len = b_string_get_size(str, B_STRLEN_IGNORE_MOD);
|
||||
printf("length = %zu\n", len);
|
||||
|
||||
b_paragraph_format format = { 0 };
|
||||
format.p_left_margin = 5;
|
||||
format.p_right_margin = 5;
|
||||
format.p_flags = B_PARAGRAPH_DOUBLE_LINE_BREAK;
|
||||
|
||||
b_print_paragraph(text, b_stdtty, &format);
|
||||
|
||||
b_i("An informational message\n\nWith multiple lines");
|
||||
b_warn("A warning message\nWith multiple lines");
|
||||
b_err("An error message\nWith multiple lines");
|
||||
|
||||
b_printf("[red]formatting ignored: '%s'[reset]\n[dark_grey]dark text[reset]\n", "[blue]wow![reset]");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user