diff options
author | Dan Davison <dandavison7@gmail.com> | 2021-08-21 10:09:28 -0700 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2021-08-21 10:09:28 -0700 |
commit | ad52c74fab1c6fae77af35487c47af10bd7546a1 (patch) | |
tree | c9818137f18512ac835a968b598f9013d8d3710d /src | |
parent | d29bf95767d6b03075ac6382ce8e2034fd753725 (diff) |
Add some test coverage for truncate_str with a multibyte unicode character
https://graphemica.com/%DD%B6
Ref #677
Diffstat (limited to 'src')
-rw-r--r-- | src/ansi/mod.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/ansi/mod.rs b/src/ansi/mod.rs index 33f4e3e7..442ead85 100644 --- a/src/ansi/mod.rs +++ b/src/ansi/mod.rs @@ -126,10 +126,10 @@ fn strip_ansi_codes_from_strings_iterator<'a>( #[cfg(test)] mod tests { - + // Note that src/ansi/console_tests.rs contains additional test coverage for this module. use super::{ ansi_preserving_slice, measure_text_width, parse_first_style, - string_starts_with_ansi_style_sequence, strip_ansi_codes, + string_starts_with_ansi_style_sequence, strip_ansi_codes, truncate_str, }; #[test] @@ -206,4 +206,13 @@ mod tests { "\x1b[1;36m\x1b[m\x1b[1;36m2222·2222·2222·2222\x1b[m\n" ) } + + #[test] + fn test_truncate_str() { + assert_eq!(truncate_str("1", 1, ""), "1"); + assert_eq!(truncate_str("12", 1, ""), "1"); + assert_eq!(truncate_str("123", 2, "s"), "1s"); + assert_eq!(truncate_str("123", 2, "→"), "1→"); + assert_eq!(truncate_str("12ݶ", 1, "ݶ"), "ݶ"); + } } |