Skip to content

Commit

Permalink
lib: add minimal test for #129
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeisler committed Apr 8, 2018
1 parent 80da774 commit 5eea30c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ Issues closed:
* Fixed [#99][issue-99]: Word broken even though it would fit on line.
* Fixed [#107][issue-107]: Automatic hyphenation is off by one.
* Fixed [#122][issue-122]: Take newlines into account when wrapping.
* Fixed [#129][issue-129]: Panic on string with em-dash.

### Version 0.9.0 — October 5th, 2017

Expand Down Expand Up @@ -335,4 +336,5 @@ Contributions will be accepted under the same license.
[issue-101]: https://github.com/mgeisler/textwrap/issues/101
[issue-107]: https://github.com/mgeisler/textwrap/issues/107
[issue-122]: https://github.com/mgeisler/textwrap/issues/122
[issue-129]: https://github.com/mgeisler/textwrap/issues/129
[mit]: LICENSE
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,13 @@ mod tests {
vec!["aaabbbccc", "x", "yyyzzzwww"]);
}

#[test]
fn issue_129() {
// The dash is an em-dash which takes up four bytes. We used
// to panic since we tried to index into the character.
assert_eq!(wrap("x – x", 1), vec!["x", "–", "x"]);
}

#[test]
fn wide_character_handling() {
assert_eq!(wrap("Hello, World!", 15), vec!["Hello, World!"]);
Expand Down

0 comments on commit 5eea30c

Please sign in to comment.