Rework of justification algorithm

I knew there was some specific cases for this justification task, but after doing more deep research, even the others algorithms are not the same at all !

A simple “task” and so many differents outputs.

Those specific cases are :

  1. begins by a spaces ≤ max_length_line
  2. begins by a spaces > max_length_line
  3. if the line ends by space/spaces after a word
// example for a little string
[             salut s
comment ca va ?]
/*Break words: no
Justify last line: yes
Nbr of characters per line: 50*/

Untitled

Untitled

Untitled

Untitled

Untitled

NONE of them displayed the same text.

With a lot of thought, since the subject didn’t specify any rules about managing spaces, i decided to not change my algorithm. Plus, i couldn’t find online the same patterns, on which am i supposed to base on then?

I think i lost a great time on it and finally, it justs depends on how it is implemented.

Though, i reworked on how the spaces are spread between words.

Tests

During the project, I managed to carry out a lot of manual tests, which turned out to be quite manageable even after making changes to the code. However, I wish I had dedicated more time on learning how to integrate Testing earlier in the project.

At the end, i had a bit of more time, so I ended up implementing them with the help of this source: https://dev.to/nathan_sheryak/how-to-test-a-typescript-express-api-with-jest-for-dummies-like-me-4epd