Skip to content

Commit

Permalink
Merge pull request #2 from jessarcher/patch-1
Browse files Browse the repository at this point in the history
Add failing wordwrap tests
  • Loading branch information
inxilpro authored Apr 18, 2024
2 parents 780cfa4 + f26dc56 commit 5294db3
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/Unit/AnsiStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,37 @@ public function test_ends_with(): void
$this->assertTrue($string->endsWith("world", true));
$this->assertTrue($string->endsWith("\e[3mworld", true));
}

public function test_it_cuts_long_words_when_wrapping(): void
{
$input = "Cut long words";

$expected = <<<EOF
Cut
Lon
g w
ord
s
EOF;

$parsed = new AnsiString($input);

$this->assertEquals($expected, (string) $parsed->wordwrap(3, cut_long_words: true));
}

public function test_it_wraps_wide_characters(): void
{
$input = 'πŸ”₯ πŸ”₯ あ あ';

$expected = <<<EOF
πŸ”₯
πŸ”₯
あ
あ
EOF;

$parsed = new AnsiString($input);

$this->assertEquals($expected, (string) $parsed->wordwrap(3));
}
}

0 comments on commit 5294db3

Please sign in to comment.