mirror of
https://github.com/ascii-boxes/boxes.git
synced 2025-01-05 21:49:04 +01:00
Test and fix more comparison types in box removal
This commit is contained in:
parent
2a2111cfae
commit
863c7c1f7b
@ -24,6 +24,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "boxes.h"
|
||||
#include "bxstring.h"
|
||||
#include "cmdline.h"
|
||||
#include "discovery.h"
|
||||
#include "generate.h"
|
||||
|
@ -400,6 +400,9 @@ static int hmm_shiftable(shape_line_ctx_t *shapes_relevant, uint32_t *cur_pos, s
|
||||
if (p != NULL && p < end_pos && is_blank_between(cur_pos, p)) {
|
||||
result = hmm(shapes_relevant, p + quality, i + (shapes_relevant[i].elastic ? 0 : 1),
|
||||
end_pos, 1, anchored_right);
|
||||
if (result == 0 && shapes_relevant[i].elastic) {
|
||||
result = hmm(shapes_relevant, p + quality, i + 1, end_pos, 1, anchored_right);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (can_shorten_right == -1) {
|
||||
@ -521,6 +524,9 @@ static int match_horiz_line(remove_ctx_t *ctx, int hside, size_t input_line_idx,
|
||||
continue;
|
||||
}
|
||||
ctx->comp_type = comp_type;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " Setting comparison type to: %s\n", comparison_name[comp_type]);
|
||||
#endif
|
||||
|
||||
shape_line_ctx_t *shapes_relevant = prepare_comp_shapes_horiz(hside, comp_type, shape_line_idx);
|
||||
debug_print_shapes_relevant(shapes_relevant);
|
||||
|
@ -566,6 +566,14 @@ int is_csi_reset(const uint32_t *csi)
|
||||
if (puc >= 0x40 && puc <= 0x7e) {
|
||||
return 1;
|
||||
}
|
||||
else if ((puc == '1' && *rest == '0')
|
||||
|| (puc == '3' && *rest == '9')
|
||||
|| (puc == '4' && *rest == '9')
|
||||
|| (puc == '5' && *rest == '9')
|
||||
|| (puc == '7' && *rest == '5')) {
|
||||
rest = u32_next(&puc, rest);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
10
src/tools.h
10
src/tools.h
@ -156,10 +156,12 @@ size_t count_invisible_chars(const uint32_t *s, size_t *num_esc, char **ascii, s
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether the given sequence of characters is a CSI (also called "escape sequence") that resets all
|
||||
* modifications, typically `ESC[0m`.
|
||||
* @param csi a pointer into a zero-terminated UTF-32 string
|
||||
* @returns 1 if true, 0 if false
|
||||
* Determine if `csi` points at a CSI which can be considered a "reset" sequence.
|
||||
* https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
|
||||
* We recognize `\x1b[0m`, and also 10, 39, 49, 59, and 75 instead of 0 as "resets", because they all serve to reset
|
||||
* the terminal to some default. Especially, lolcat uses `\x1b[39m` as reset CSI.
|
||||
* @param csi a string which might or might not be a CSI "reset" sequence (zero-terminated UTF-32 string)
|
||||
* @return 1 if it was a CSI "reset", 0 otherwise
|
||||
*/
|
||||
int is_csi_reset(const uint32_t *csi);
|
||||
|
||||
|
28
test/181_remove_box_ignore_invisible_all.txt
Normal file
28
test/181_remove_box_ignore_invisible_all.txt
Normal file
@ -0,0 +1,28 @@
|
||||
:DESC
|
||||
Remove a box consisting of unicode characters and ansi escape codes, even when the colors are all wrong (input box
|
||||
has different colors than the box design).
|
||||
Boxes shall recognize a box design by the visible characters, not by the colors.
|
||||
This tests the comparison mode 'ignore_invisible_all'.
|
||||
|
||||
:ARGS
|
||||
--config 18x_remove_box_ignore_invisible_all.cfg --remove
|
||||
:INPUT
|
||||
[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;84m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m.[39m[38;5;83m-[39m[38;5;83m"[39m[38;5;83m`[39m[38;5;83m`[39m[38;5;83m`[39m[38;5;119m"[39m[38;5;118m-[39m[38;5;118m.[39m[38;5;118m[39m
|
||||
[38;5;84m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m/[39m[38;5;83m_[39m[38;5;83m_[39m[38;5;83m_[39m[38;5;119m_[39m[38;5;118m_[39m[38;5;118m_[39m[38;5;118m_[39m[38;5;118m;[39m[38;5;118m [39m[38;5;118m\[39m[38;5;118m[39m
|
||||
[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m([39m[38;5;83m_[39m[38;5;119m_[39m[38;5;118m_[39m[38;5;118m_[39m[38;5;118m_[39m[38;5;118m_[39m[38;5;118m_[39m[38;5;118m_[39m[38;5;118m_[39m[38;5;118m)[39m[38;5;118m\[39m[38;5;154m|[39m[38;5;154m[39m
|
||||
[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;119m [39m[38;5;118m/[39m[38;5;118m [39m[38;5;118m/[39m[38;5;118m [39m[38;5;118m👁[39m[38;5;118m [39m[38;5;118m👁[39m[38;5;118m [39m[38;5;118m\[39m[38;5;154m [39m[38;5;154m\[39m[38;5;154m([39m[38;5;154m_[39m[38;5;154m)[39m[38;5;154m[39m
|
||||
[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;119m [39m[38;5;118m [39m[38;5;118m [39m[38;5;118m/[39m[38;5;118m [39m[38;5;118m([39m[38;5;118m [39m[38;5;118m\[39m[38;5;118m_[39m[38;5;118m_[39m[38;5;154m_[39m[38;5;154m/[39m[38;5;154m [39m[38;5;154m)[39m[38;5;154m [39m[38;5;154m\[39m[38;5;154m[39m
|
||||
[38;5;119m [39m[38;5;118m [39m[38;5;118m_[39m[38;5;118mo[39m[38;5;118mo[39m[38;5;118mo[39m[38;5;118m\[39m[38;5;118m_[39m[38;5;118m_[39m[38;5;118m\[39m[38;5;154m_[39m[38;5;154m_[39m[38;5;154m_[39m[38;5;154m_[39m[38;5;154m_[39m[38;5;154m/[39m[38;5;154m_[39m[38;5;154m_[39m[38;5;154m/[39m[38;5;154m_[39m[38;5;148m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m[39m
|
||||
[38;5;118m [39m[38;5;118m/[39m[38;5;118m [39m[38;5;118m [39m[38;5;118m [39m[38;5;118m [39m[38;5;118m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;148m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m\[0m[38;5;184m[39m
|
||||
[38;5;118m|[39m[38;5;118m [39m[38;5;118m [39m[38;5;118m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154mH[39m[38;5;154me[39m[38;5;154ml[39m[38;5;154ml[39m[38;5;154mo[39m[38;5;154m [39m[38;5;154mW[39m[38;5;154mo[39m[38;5;148mr[39m[38;5;184ml[39m[38;5;184md[39m[38;5;184m![39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m|[39m[38;5;184m[39m
|
||||
[38;5;118m [39m[38;5;154m\[39m[38;5;154m_[39m[38;5;154m_[39m[38;5;154m_[39m[38;5;154m_[39m[38;5;154m_[39m[38;5;154m_[39m[38;5;154m_[39m[38;5;154m_[39m[38;5;154m_[39m[38;5;148m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184mo[39m[38;5;184mo[39m[38;5;184mo[39m[38;5;184m_[39m[38;5;178m/[39m[38;5;214m[39m
|
||||
[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m/[39m[38;5;154m [39m[38;5;148m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m\[39m[38;5;184m[39m
|
||||
[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;148m/[39m[38;5;184m:[39m[38;5;184m.[39m[38;5;184m:[39m[38;5;184m.[39m[38;5;184m:[39m[38;5;184m.[39m[38;5;184m:[39m[38;5;184m.[39m[38;5;184m:[39m[38;5;184m.[39m[38;5;184m:[39m[38;5;178m.[39m[38;5;214m:[39m[38;5;214m\[39m[38;5;214m[39m
|
||||
[38;5;154m [39m[38;5;154m [39m[38;5;148m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m|[39m[38;5;184m [39m[38;5;184m [39m[38;5;184m|[39m[38;5;184m [39m[38;5;178m [39m[38;5;214m|[39m[38;5;214m[39m
|
||||
[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m\[39m[38;5;184m=[39m[38;5;178m=[39m[38;5;214m|[39m[38;5;214m=[39m[38;5;214m=[39m[38;5;214m/[39m[38;5;214m [39m[38;5;214m [39m[38;5;214mj[39m[38;5;214mg[39m[38;5;214ms[39m[38;5;208m[39m
|
||||
[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;178m [39m[38;5;214m/[39m[38;5;214m-[39m[38;5;214m'[39m[38;5;214mY[39m[38;5;214m'[39m[38;5;214m-[39m[38;5;214m\[39m[38;5;214m[39m
|
||||
[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;178m [39m[38;5;214m [39m[38;5;214m [39m[38;5;214m([39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m/[39m[38;5;214m [39m[38;5;214m\[39m[38;5;214m_[39m[38;5;208m_[39m[38;5;208m)[39m[38;5;208m[39m
|
||||
:OUTPUT-FILTER
|
||||
:EXPECTED
|
||||
[38;5;118m [39m[38;5;118m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154mH[39m[38;5;154me[39m[38;5;154ml[39m[38;5;154ml[39m[38;5;154mo[39m[38;5;154m [39m[38;5;154mW[39m[38;5;154mo[39m[38;5;148mr[39m[38;5;184ml[39m[38;5;184md[39m[38;5;184m![39m
|
||||
:EOF
|
26
test/182_remove_box_ignore_invisible_shape.txt
Normal file
26
test/182_remove_box_ignore_invisible_shape.txt
Normal file
@ -0,0 +1,26 @@
|
||||
:DESC
|
||||
In this test case, the box design is fully colored, but the input is monochrome.
|
||||
This tests the comparison mode 'ignore_invisible_shape'.
|
||||
|
||||
:ARGS
|
||||
--config 18x_remove_box_ignore_invisible_all.cfg --design designA --remove
|
||||
:INPUT
|
||||
.-"```"-.
|
||||
/_______; \
|
||||
(_________)\|
|
||||
/ / 👁 👁 \ \(_)
|
||||
/ ( \___/ ) \
|
||||
_ooo\__\_____/__/____
|
||||
/ \
|
||||
| Hello World! |
|
||||
\_________________ooo_/
|
||||
/ \
|
||||
/:.:.:.:.:.:.:\
|
||||
| | |
|
||||
\==|==/ jgs
|
||||
/-'Y'-\
|
||||
(__/ \__)
|
||||
:OUTPUT-FILTER
|
||||
:EXPECTED
|
||||
Hello World!
|
||||
:EOF
|
28
test/183_remove_box_ignore_invisible_input.txt
Normal file
28
test/183_remove_box_ignore_invisible_input.txt
Normal file
@ -0,0 +1,28 @@
|
||||
:DESC
|
||||
In this test case, the box design is monochrome, but the input is colored.
|
||||
This tests the comparison mode 'ignore_invisible_input'.
|
||||
|
||||
:ARGS
|
||||
--design capgirl --remove
|
||||
:INPUT
|
||||
[38;5;39m [39m[38;5;39m [39m[38;5;39m [39m[38;5;39m [39m[38;5;39m [39m[38;5;39m [39m[38;5;39m [39m[38;5;39m [39m[38;5;39m [39m[38;5;38m.[39m[38;5;44m-[39m[38;5;44m"[39m[38;5;44m`[39m[38;5;44m`[39m[38;5;44m`[39m[38;5;44m"[39m[38;5;44m-[39m[38;5;44m.[39m[38;5;44m[39m
|
||||
[38;5;39m [39m[38;5;39m [39m[38;5;39m [39m[38;5;39m [39m[38;5;39m [39m[38;5;39m [39m[38;5;38m [39m[38;5;44m [39m[38;5;44m/[39m[38;5;44m_[39m[38;5;44m_[39m[38;5;44m_[39m[38;5;44m_[39m[38;5;44m_[39m[38;5;44m_[39m[38;5;44m_[39m[38;5;44m;[39m[38;5;44m [39m[38;5;43m\[39m[38;5;49m[39m
|
||||
[38;5;39m [39m[38;5;39m [39m[38;5;39m [39m[38;5;38m [39m[38;5;44m [39m[38;5;44m [39m[38;5;44m [39m[38;5;44m([39m[38;5;44m_[39m[38;5;44m_[39m[38;5;44m_[39m[38;5;44m_[39m[38;5;44m_[39m[38;5;44m_[39m[38;5;44m_[39m[38;5;43m_[39m[38;5;49m_[39m[38;5;49m)[39m[38;5;49m\[39m[38;5;49m|[39m[38;5;49m[39m
|
||||
[38;5;38m [39m[38;5;44m [39m[38;5;44m [39m[38;5;44m [39m[38;5;44m [39m[38;5;44m [39m[38;5;44m [39m[38;5;44m/[39m[38;5;44m [39m[38;5;44m/[39m[38;5;44m [39m[38;5;44ma[39m[38;5;43m [39m[38;5;49ma[39m[38;5;49m [39m[38;5;49m\[39m[38;5;49m [39m[38;5;49m\[39m[38;5;49m([39m[38;5;49m_[39m[38;5;49m)[39m[38;5;49m[39m
|
||||
[38;5;44m [39m[38;5;44m [39m[38;5;44m [39m[38;5;44m [39m[38;5;44m [39m[38;5;44m [39m[38;5;44m/[39m[38;5;44m [39m[38;5;44m([39m[38;5;43m [39m[38;5;49m\[39m[38;5;49m_[39m[38;5;49m_[39m[38;5;49m_[39m[38;5;49m/[39m[38;5;49m [39m[38;5;49m)[39m[38;5;49m [39m[38;5;49m\[39m[38;5;48m[39m
|
||||
[38;5;44m [39m[38;5;44m [39m[38;5;44m_[39m[38;5;44mo[39m[38;5;44mo[39m[38;5;44mo[39m[38;5;43m\[39m[38;5;49m_[39m[38;5;49m_[39m[38;5;49m\[39m[38;5;49m_[39m[38;5;49m_[39m[38;5;49m_[39m[38;5;49m_[39m[38;5;49m_[39m[38;5;49m/[39m[38;5;48m_[39m[38;5;48m_[39m[38;5;48m/[39m[38;5;48m_[39m[38;5;48m_[39m[38;5;48m_[39m[38;5;48m_[39m[38;5;48m[39m
|
||||
[38;5;44m [39m[38;5;44m/[39m[38;5;44m [39m[38;5;43m [39m[38;5;49m [39m[38;5;49m [39m[38;5;49m [39m[38;5;49m [39m[38;5;49m [39m[38;5;49m [39m[38;5;49m [39m[38;5;49m [39m[38;5;49m [39m[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;84m [39m[38;5;83m\[39m[38;5;83m[39m
|
||||
[38;5;43m|[39m[38;5;49m [39m Hello, world! [38;5;83m [39m[38;5;83m|[39m[38;5;83m[39m
|
||||
[38;5;49m|[39m[38;5;49m [39m World, hello! [38;5;83m [39m[38;5;83m|[39m[38;5;83m[39m
|
||||
[38;5;49m [39m[38;5;49m\[39m[38;5;49m_[39m[38;5;49m_[39m[38;5;48m_[39m[38;5;48m_[39m[38;5;48m_[39m[38;5;48m_[39m[38;5;48m_[39m[38;5;48m_[39m[38;5;48m_[39m[38;5;48m_[39m[38;5;48m_[39m[38;5;84m_[39m[38;5;83m_[39m[38;5;83m_[39m[38;5;83m_[39m[38;5;83m_[39m[38;5;83m_[39m[38;5;83mo[39m[38;5;83mo[39m[38;5;83mo[39m[38;5;83m_[39m[38;5;83m/[39m[38;5;83m[39m
|
||||
[38;5;49m [39m[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;48m/[39m[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;84m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m\[39m[38;5;83m[39m
|
||||
[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;48m/[39m[38;5;48m:[39m[38;5;84m.[39m[38;5;83m:[39m[38;5;83m.[39m[38;5;83m:[39m[38;5;83m.[39m[38;5;83m:[39m[38;5;83m.[39m[38;5;83m:[39m[38;5;83m.[39m[38;5;83m:[39m[38;5;83m.[39m[38;5;83m:[39m[38;5;119m\[39m[38;5;118m[39m
|
||||
[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;48m [39m[38;5;84m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m|[39m[38;5;83m [39m[38;5;83m [39m[38;5;83m|[39m[38;5;83m [39m[38;5;83m [39m[38;5;83m|[39m[38;5;119m[39m
|
||||
[38;5;48m [39m[38;5;84m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m\[39m[38;5;83m=[39m[38;5;83m=[39m[38;5;83m|[39m[38;5;119m=[39m[38;5;118m=[39m[38;5;118m/[39m[38;5;118m [39m[38;5;118m [39m[38;5;118mj[39m[38;5;118mg[39m[38;5;118ms[39m[38;5;118m[39m
|
||||
[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m/[39m[38;5;119m-[39m[38;5;118m'[39m[38;5;118mY[39m[38;5;118m'[39m[38;5;118m-[39m[38;5;118m\[39m[38;5;118m[39m
|
||||
[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;83m [39m[38;5;119m [39m[38;5;118m([39m[38;5;118m_[39m[38;5;118m_[39m[38;5;118m/[39m[38;5;118m [39m[38;5;118m\[39m[38;5;118m_[39m[38;5;118m_[39m[38;5;118m)[39m[38;5;154m[39m
|
||||
:OUTPUT-FILTER
|
||||
:EXPECTED
|
||||
Hello, world!
|
||||
World, hello!
|
||||
:EOF
|
71
test/18x_remove_box_ignore_invisible_all.cfg
Normal file
71
test/18x_remove_box_ignore_invisible_all.cfg
Normal file
@ -0,0 +1,71 @@
|
||||
# A fully lolcat-colored box including unicode eyes.
|
||||
|
||||
BOX designA
|
||||
|
||||
sample
|
||||
[38;5;118m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m.[39m[38;5;154m-[39m[38;5;148m"[39m[38;5;184m`[39m[38;5;184m`[39m[38;5;184m`[39m[38;5;184m"[39m[38;5;184m-[39m[38;5;184m.[39m[38;5;184m[39m
|
||||
[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;148m/[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m;[39m[38;5;184m [39m[38;5;184m\[39m[38;5;184m[39m
|
||||
[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;148m [39m[38;5;184m [39m[38;5;184m([39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;178m)[39m[38;5;214m\[39m[38;5;214m|[39m[38;5;214m[39m
|
||||
[38;5;154m [39m[38;5;154m [39m[38;5;148m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m/[39m[38;5;184m [39m[38;5;184m/[39m[38;5;184m [39m[38;5;184m👁[39m[38;5;184m [39m[38;5;184m👁[39m[38;5;178m [39m[38;5;214m\[39m[38;5;214m [39m[38;5;214m\[39m[38;5;214m([39m[38;5;214m_[39m[38;5;214m)[39m[38;5;214m[39m
|
||||
[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m/[39m[38;5;184m [39m[38;5;184m([39m[38;5;184m [39m[38;5;184m\[39m[38;5;178m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m/[39m[38;5;214m [39m[38;5;214m)[39m[38;5;214m [39m[38;5;214m\[39m[38;5;214m[39m
|
||||
[38;5;184m [39m[38;5;184m [39m[38;5;184m_[39m[38;5;184mo[39m[38;5;184mo[39m[38;5;184mo[39m[38;5;184m\[39m[38;5;184m_[39m[38;5;178m_[39m[38;5;214m\[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m/[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;208m/[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m[39m
|
||||
[38;5;184m [39m[38;5;184m/[39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;178m [39m[38;5;214m [39m[38;5;214m [39m[38;5;214m [39m[38;5;214m [39m[38;5;214m [39m[38;5;214m [39m[38;5;214m [39m[38;5;214m [39m[38;5;214m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m\[39m[38;5;209m[39m
|
||||
[38;5;184m|[39m[38;5;184m [39m[38;5;178m [39m[38;5;214m [39m[38;5;214m [39m[38;5;214m [39m[38;5;214mH[39m[38;5;214me[39m[38;5;214ml[39m[38;5;214ml[39m[38;5;214mo[39m[38;5;214m [39m[38;5;208mW[39m[38;5;208mo[39m[38;5;208mr[39m[38;5;208ml[39m[38;5;208md[39m[38;5;208m![39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;209m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m|[39m[38;5;203m[39m
|
||||
[38;5;214m [39m[38;5;214m\[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;209m_[39m[38;5;203mo[39m[38;5;203mo[39m[38;5;203mo[39m[38;5;203m_[39m[38;5;203m/[39m[38;5;203m[39m
|
||||
[38;5;214m [39m[38;5;214m [39m[38;5;214m [39m[38;5;214m [39m[38;5;214m [39m[38;5;214m [39m[38;5;208m/[39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;209m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m\[39m[38;5;203m[39m
|
||||
[38;5;214m [39m[38;5;214m [39m[38;5;214m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m/[39m[38;5;208m:[39m[38;5;208m.[39m[38;5;208m:[39m[38;5;208m.[39m[38;5;208m:[39m[38;5;208m.[39m[38;5;209m:[39m[38;5;203m.[39m[38;5;203m:[39m[38;5;203m.[39m[38;5;203m:[39m[38;5;203m.[39m[38;5;203m:[39m[38;5;203m\[39m[38;5;203m[39m
|
||||
[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;209m|[39m[38;5;203m [39m[38;5;203m [39m[38;5;203m|[39m[38;5;203m [39m[38;5;203m [39m[38;5;203m|[39m[38;5;203m[39m
|
||||
[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;209m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m\[39m[38;5;203m=[39m[38;5;203m=[39m[38;5;203m|[39m[38;5;203m=[39m[38;5;203m=[39m[38;5;203m/[39m[38;5;203m [39m[38;5;203m [39m[38;5;204mj[39m[38;5;198mg[39m[38;5;198ms[39m[38;5;198m[39m
|
||||
[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;209m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m/[39m[38;5;203m-[39m[38;5;203m'[39m[38;5;203mY[39m[38;5;203m'[39m[38;5;203m-[39m[38;5;204m\[39m[38;5;198m[39m
|
||||
[38;5;209m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m([39m[38;5;203m_[39m[38;5;203m_[39m[38;5;203m/[39m[38;5;204m [39m[38;5;198m\[39m[38;5;198m_[39m[38;5;198m_[39m[38;5;198m)[39m[38;5;198m[39m
|
||||
ends
|
||||
|
||||
# Monochrome sample:
|
||||
# .-"```"-.
|
||||
# /_______; \
|
||||
# (_________)\|
|
||||
# / / 👁 👁 \ \(_)
|
||||
# / ( \___/ ) \
|
||||
# _ooo\__\_____/__/____
|
||||
# / \
|
||||
# | Hello World! |
|
||||
# \_________________ooo_/
|
||||
# / \
|
||||
# /:.:.:.:.:.:.:\
|
||||
# | | |
|
||||
# \==|==/ jgs
|
||||
# /-'Y'-\
|
||||
# (__/ \__)
|
||||
|
||||
delim ~"
|
||||
|
||||
shapes {
|
||||
n ("[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m.[39m[38;5;154m-[39m[38;5;148m~"[39m[38;5;184m`[39m[38;5;184m`[39m[38;5;184m`[39m[38;5;184m~"[39m[38;5;184m-[39m[38;5;184m.[39m ",
|
||||
"[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;154m [39m[38;5;148m/[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m;[39m[38;5;184m [39m[38;5;184m\[39m ",
|
||||
"[38;5;154m [39m[38;5;154m [39m[38;5;148m [39m[38;5;184m [39m[38;5;184m([39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;184m_[39m[38;5;178m)[39m[38;5;214m\[39m[38;5;214m|[39m ",
|
||||
"[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m/[39m[38;5;184m [39m[38;5;184m/[39m[38;5;184m [39m[38;5;184m👁[39m[38;5;184m [39m[38;5;184m👁[39m[38;5;178m [39m[38;5;214m\[39m[38;5;214m [39m[38;5;214m\[39m[38;5;214m([39m[38;5;214m_[39m[38;5;214m)[39m ",
|
||||
"[38;5;184m [39m[38;5;184m [39m[38;5;184m [39m[38;5;184m/[39m[38;5;184m [39m[38;5;184m([39m[38;5;184m [39m[38;5;184m\[39m[38;5;178m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m/[39m[38;5;214m [39m[38;5;214m)[39m[38;5;214m [39m[38;5;214m\[39m ",
|
||||
"[38;5;184mo[39m[38;5;184mo[39m[38;5;184mo[39m[38;5;184m\[39m[38;5;184m_[39m[38;5;178m_[39m[38;5;214m\[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m/[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;208m/[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m",
|
||||
" ")
|
||||
s ("[38;5;214m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;214m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;208m_[39m[38;5;209m_[39m[38;5;203mo[39m[38;5;203mo[39m[38;5;203mo[39m",
|
||||
"[38;5;214m [39m[38;5;214m [39m[38;5;214m [39m[38;5;208m/[39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;209m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m\[39m ",
|
||||
"[38;5;208m [39m[38;5;208m [39m[38;5;208m/[39m[38;5;208m:[39m[38;5;208m.[39m[38;5;208m:[39m[38;5;208m.[39m[38;5;208m:[39m[38;5;208m.[39m[38;5;209m:[39m[38;5;203m.[39m[38;5;203m:[39m[38;5;203m.[39m[38;5;203m:[39m[38;5;203m.[39m[38;5;203m:[39m[38;5;203m\[39m ",
|
||||
"[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;209m|[39m[38;5;203m [39m[38;5;203m [39m[38;5;203m|[39m[38;5;203m [39m[38;5;203m [39m[38;5;203m|[39m ",
|
||||
"[38;5;208m [39m[38;5;208m [39m[38;5;208m [39m[38;5;209m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m\[39m[38;5;203m=[39m[38;5;203m=[39m[38;5;203m|[39m[38;5;203m=[39m[38;5;203m=[39m[38;5;203m/[39m[38;5;203m [39m[38;5;203m [39m[38;5;204mj[39m[38;5;198mg[39m[38;5;198ms[39m ",
|
||||
"[38;5;209m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m/[39m[38;5;203m-[39m[38;5;203m'[39m[38;5;203mY[39m[38;5;203m'[39m[38;5;203m-[39m[38;5;204m\[39m ",
|
||||
"[38;5;203m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m [39m[38;5;203m([39m[38;5;203m_[39m[38;5;203m_[39m[38;5;203m/[39m[38;5;204m [39m[38;5;198m\[39m[38;5;198m_[39m[38;5;198m_[39m[38;5;198m)[39m ")
|
||||
e ("[38;5;203m [39m[38;5;203m|[39m")
|
||||
w ("[38;5;184m|[39m[38;5;184m [39m")
|
||||
sw (" [38;5;214m\[39m", " ", " ", " ", " ", " ", " ")
|
||||
se ("[38;5;203m/[39m ", " ", " ", " ", " ", " ", " ")
|
||||
ssw ("[38;5;214m_[39m", " ", " ", " ", " ", " ", " ")
|
||||
sse ("[38;5;203m_[39m", " ", " ", " ", " ", " ", " ")
|
||||
nw (" ", " ", " ", " ", " ", " ", " [38;5;184m/[39m")
|
||||
nnw (" ", " ", " ", " ", " ", "[38;5;184m_[39m", " ")
|
||||
nne (" ", " ", " ", " ", " ", "[38;5;208m_[39m", " ")
|
||||
ne (" ", " ", " ", " ", " ", " ", "[38;5;208m\[0m ")
|
||||
}
|
||||
|
||||
elastic (nne,nnw, sse,ssw, e, w)
|
||||
|
||||
END designA
|
@ -353,6 +353,34 @@ void test_ansi_unicode_null(void **state)
|
||||
|
||||
|
||||
|
||||
void test_ansi_unicode_tc183(void **state)
|
||||
{
|
||||
UNUSED(state);
|
||||
|
||||
uint32_t *ustr32 = u32_strconv_from_arg("\x1b[38;5;43m|\x1b[39m\x1b[38;5;49m \x1b[39m X", "ASCII");
|
||||
assert_non_null(ustr32);
|
||||
bxstr_t *actual = bxs_from_unicode(ustr32);
|
||||
|
||||
assert_non_null(actual);
|
||||
assert_non_null(actual->memory);
|
||||
assert_string_equal("| X", actual->ascii);
|
||||
assert_int_equal(0, (int) actual->indent);
|
||||
assert_int_equal(7, (int) actual->num_columns);
|
||||
assert_int_equal(37, (int) actual->num_chars);
|
||||
assert_int_equal(7, (int) actual->num_chars_visible);
|
||||
assert_int_equal(30, (int) actual->num_chars_invisible);
|
||||
assert_int_equal(0, (int) actual->trailing);
|
||||
int expected_firstchar_idx[] = {0, 16, 32, 33, 34, 35, 36, 37};
|
||||
assert_array_equal(expected_firstchar_idx, actual->first_char, 8);
|
||||
int expected_vischar_idx[] = {10, 26, 32, 33, 34, 35, 36, 37};
|
||||
assert_array_equal(expected_vischar_idx, actual->visible_char, 8);
|
||||
|
||||
BFREE(ustr32);
|
||||
bxs_free(actual);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void test_bxs_new_empty_string(void **state)
|
||||
{
|
||||
UNUSED(state);
|
||||
|
@ -35,6 +35,7 @@ void test_ansi_unicode_illegalchar(void **state);
|
||||
void test_ansi_unicode_tabs(void **state);
|
||||
void test_ansi_unicode_broken_escapes(void **state);
|
||||
void test_ansi_unicode_null(void **state);
|
||||
void test_ansi_unicode_tc183(void **state);
|
||||
|
||||
void test_bxs_new_empty_string(void **state);
|
||||
|
||||
|
@ -135,6 +135,7 @@ int main(void)
|
||||
cmocka_unit_test_setup(test_ansi_unicode_tabs, beforeTest),
|
||||
cmocka_unit_test_setup(test_ansi_unicode_broken_escapes, beforeTest),
|
||||
cmocka_unit_test_setup(test_ansi_unicode_null, beforeTest),
|
||||
cmocka_unit_test_setup(test_ansi_unicode_tc183, beforeTest),
|
||||
cmocka_unit_test_setup(test_bxs_new_empty_string, beforeTest),
|
||||
cmocka_unit_test_setup(test_bxs_is_blank, beforeTest),
|
||||
cmocka_unit_test_setup(test_bxs_strdup, beforeTest),
|
||||
|
Loading…
Reference in New Issue
Block a user