mirror of
https://github.com/ascii-boxes/boxes.git
synced 2025-02-03 19:39:34 +01:00
Add test cases for removal of colored boxes
This commit is contained in:
parent
beb8696a79
commit
352a7b6d5d
@ -976,7 +976,7 @@ int remove_box()
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "memmove(\"%s\", \"%s\", %d);\n",
|
||||
input.lines[j].text, input.lines[j].text + c, (int) (input.lines[j].len - c + 1));
|
||||
#endif
|
||||
@ -984,7 +984,12 @@ int remove_box()
|
||||
input.lines[j].len - c + 1); /* +1 for zero byte */
|
||||
input.lines[j].len -= c;
|
||||
|
||||
/* TODO the next line may kill an escape code to color the next char */
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "u32_move(\"%s\", \"%s\", %d); // posmap[c]=%d\n",
|
||||
u32_strconv_to_output(input.lines[j].mbtext),
|
||||
u32_strconv_to_output(input.lines[j].mbtext + input.lines[j].posmap[c]),
|
||||
(int) (input.lines[j].num_chars - c + 1), (int) input.lines[j].posmap[c]);
|
||||
#endif
|
||||
u32_move(input.lines[j].mbtext, input.lines[j].mbtext + input.lines[j].posmap[c],
|
||||
input.lines[j].num_chars - c + 1); /* +1 for zero byte */
|
||||
input.lines[j].num_chars -= c;
|
||||
|
@ -197,7 +197,7 @@ void concat_strings(char *dst, int max_len, int count, ...)
|
||||
/*
|
||||
* Concatenate 'src' onto 'dst', as long as we have room.
|
||||
*/
|
||||
while (*src && max_len > 1) { // TODO Can this be improved via strcpy
|
||||
while (*src && max_len > 1) {
|
||||
*dst++ = *src++;
|
||||
max_len--;
|
||||
}
|
||||
|
@ -9,8 +9,10 @@ box was created.
|
||||
:INPUT
|
||||
/**************************/
|
||||
/* [38;5;44mf [0m[38;5;49mo [0m[38;5;48mo [0m[38;5;83m [0m[38;5;118m海 [0m[38;5;154m [0m[38;5;184mb [0m[38;5;214ma [0m[38;5;208mr [0m */
|
||||
/* f o o b a r */
|
||||
/**************************/
|
||||
:OUTPUT-FILTER
|
||||
:EXPECTED
|
||||
[38;5;44mf[0m[38;5;49mo[0m[38;5;48mo[0m[38;5;83m [0m[38;5;118m海[0m[38;5;154m [0m[38;5;184mb[0m[38;5;214ma[0m[38;5;208mr[0m
|
||||
foobar
|
||||
:EOF
|
||||
|
16
test/121_remove_box_lolcat.txt
Normal file
16
test/121_remove_box_lolcat.txt
Normal file
@ -0,0 +1,16 @@
|
||||
:DESC
|
||||
Remove a box which has been piped through lolcat, including the box itself and the indentation, all of which was
|
||||
colored.
|
||||
|
||||
:ARGS
|
||||
-r
|
||||
:INPUT
|
||||
[38;5;129m [0m[38;5;93m [0m[38;5;93m [0m[38;5;63m/[0m[38;5;63m*[0m[38;5;33m*[0m[38;5;33m*[0m[38;5;39m*[0m[38;5;39m*[0m[38;5;44m*[0m[38;5;44m*[0m[38;5;49m*[0m[38;5;49m*[0m[38;5;48m*[0m[38;5;48m/[0m
|
||||
[38;5;63m [0m[38;5;63m [0m[38;5;33m [0m[38;5;33m/[0m[38;5;39m*[0m[38;5;39m [0m[38;5;44mf[0m[38;5;44mo[0m[38;5;49mo[0m[38;5;49mb[0m[38;5;48ma[0m[38;5;48mr[0m[38;5;83m [0m[38;5;83m*[0m[38;5;83m/[0m
|
||||
[38;5;33m [0m[38;5;39m [0m[38;5;39m [0m[38;5;44m/[0m[38;5;44m*[0m[38;5;49m [0m[38;5;49mb[0m[38;5;48mo[0m[38;5;48mo[0m[38;5;83mf[0m[38;5;83ma[0m[38;5;83mr[0m[38;5;118m [0m[38;5;118m*[0m[38;5;154m/[0m
|
||||
[38;5;44m [0m[38;5;44m [0m[38;5;49m [0m[38;5;49m/[0m[38;5;48m*[0m[38;5;48m*[0m[38;5;83m*[0m[38;5;83m*[0m[38;5;83m*[0m[38;5;118m*[0m[38;5;118m*[0m[38;5;154m*[0m[38;5;148m*[0m[38;5;184m*[0m[38;5;184m/[0m
|
||||
:OUTPUT-FILTER
|
||||
:EXPECTED
|
||||
[0m[38;5;39m [0m[38;5;39m [0m[38;5;44mf[0m[38;5;44mo[0m[38;5;49mo[0m[38;5;49mb[0m[38;5;48ma[0m[38;5;48mr[0m
|
||||
[0m[38;5;44m [0m[38;5;49m [0m[38;5;49mb[0m[38;5;48mo[0m[38;5;48mo[0m[38;5;83mf[0m[38;5;83ma[0m[38;5;83mr[0m
|
||||
:EOF
|
Loading…
Reference in New Issue
Block a user