Add test cases for removal of colored boxes

This commit is contained in:
Thomas Jensen 2021-02-14 14:38:00 +01:00
parent beb8696a79
commit 352a7b6d5d
No known key found for this signature in database
GPG Key ID: A4ACEE270D0FB7DB
4 changed files with 26 additions and 3 deletions

View File

@ -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;

View File

@ -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--;
}

View File

@ -9,8 +9,10 @@ box was created.
:INPUT
/**************************/
/* f o o  海  b a r  */
/* f o o b a r */
/**************************/
:OUTPUT-FILTER
:EXPECTED
foo 海 bar
foobar
:EOF

View 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
   /**********/
   /* foobar */
   /* boofar */
   /**********/
:OUTPUT-FILTER
:EXPECTED
  foobar
  boofar
:EOF