yoctui-utils 0.1.315

Shared utility functions for Yoctui
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use super::*;

#[test]
fn truncation_covers_every_multibyte_boundary() {
    for (limit, expected) in [
        (0, ""),
        (1, "a"),
        (2, "a"),
        (3, "a位"),
        (4, "a位"),
        (7, "a位馃檪"),
        (99, "a位馃檪z"),
    ] {
        let mut value = "a位馃檪z".to_owned();
        truncate_utf8(&mut value, limit);
        assert_eq!(value, expected);
    }
}