Skip to content

Commit 8984d15

Browse files
renovate[bot]Aetf
authored andcommitted
fix(deps): update rust crate unicode-width to 0.2
Updated unit tests since unicode-width now returns more accurate widths for emojis.
1 parent abd6d91 commit 8984d15

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ exclude = [
2020
[dependencies]
2121
itertools = { version = "0.13", default-features = false }
2222
unicode-segmentation = { version = "1", default-features = false }
23-
unicode-width = "0.1"
23+
unicode-width = "0.2"
2424

2525
[dev-dependencies]
2626
criterion = "0.5"

src/lib.rs

+23-10
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,14 @@ mod tests {
385385
#[test]
386386
fn family_stays_together() {
387387
let input = "123👨‍👩‍👧‍👦456";
388+
389+
// Family emoji should be of width 2
390+
assert_eq!("👨‍👩‍👧‍👦".width(), 2);
391+
388392
assert_eq!(input.unicode_truncate(4), ("123", 3));
389-
assert_eq!(input.unicode_truncate(8), ("123", 3));
390-
assert_eq!(input.unicode_truncate(12), ("123👨‍👩‍👧‍👦4", 12));
391-
assert_eq!(input.unicode_truncate(20), (input, 14));
393+
assert_eq!(input.unicode_truncate(5), ("123👨‍👩‍👧‍👦", 5));
394+
assert_eq!(input.unicode_truncate(6), ("123👨‍👩‍👧‍👦4", 6));
395+
assert_eq!(input.unicode_truncate(20), (input, 8));
392396
}
393397
}
394398

@@ -442,10 +446,14 @@ mod tests {
442446
#[test]
443447
fn family_stays_together() {
444448
let input = "123👨‍👩‍👧‍👦456";
449+
450+
// Family emoji should be of width 2
451+
assert_eq!("👨‍👩‍👧‍👦".width(), 2);
452+
445453
assert_eq!(input.unicode_truncate_start(4), ("456", 3));
446-
assert_eq!(input.unicode_truncate_start(8), ("456", 3));
447-
assert_eq!(input.unicode_truncate_start(12), ("3👨‍👩‍👧‍👦456", 12));
448-
assert_eq!(input.unicode_truncate_start(20), (input, 14));
454+
assert_eq!(input.unicode_truncate_start(5), ("👨‍👩‍👧‍👦456", 5));
455+
assert_eq!(input.unicode_truncate_start(6), ("3👨‍👩‍👧‍👦456", 6));
456+
assert_eq!(input.unicode_truncate_start(20), (input, 8));
449457
}
450458
}
451459

@@ -534,10 +542,15 @@ mod tests {
534542
#[test]
535543
fn family_stays_together() {
536544
let input = "123👨‍👩‍👧‍👦456";
537-
assert_eq!(input.unicode_truncate_centered(4), ("", 0));
538-
assert_eq!(input.unicode_truncate_centered(8), ("👨‍👩‍👧‍👦", 8));
539-
assert_eq!(input.unicode_truncate_centered(12), ("23👨‍👩‍👧‍👦45", 12));
540-
assert_eq!(input.unicode_truncate_centered(20), (input, 14));
545+
546+
// Family emoji should be of width 2
547+
assert_eq!("👨‍👩‍👧‍👦".width(), 2);
548+
549+
assert_eq!(input.unicode_truncate_centered(1), ("", 0));
550+
assert_eq!(input.unicode_truncate_centered(2), ("👨‍👩‍👧‍👦", 2));
551+
assert_eq!(input.unicode_truncate_centered(4), ("3👨‍👩‍👧‍👦4", 4));
552+
assert_eq!(input.unicode_truncate_centered(6), ("23👨‍👩‍👧‍👦45", 6));
553+
assert_eq!(input.unicode_truncate_centered(20), (input, 8));
541554
}
542555
}
543556

0 commit comments

Comments
 (0)