Skip to content

Commit 2e48aa8

Browse files
committed
decrease version to 0.15.12 & few more tests
This MR only adds a new function to the API so that's a minor change, which are the z component in 0.y.z versions.
1 parent ed700f8 commit 2e48aa8

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Newer changelog entries can be found [on
44
GitHub](https://github.com/console-rs/console/releases).
55

6-
## 0.16.0
6+
## 0.15.12
77

88
### Enhancements
99

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "console"
33
description = "A terminal and console abstraction for Rust"
4-
version = "0.16.0"
4+
version = "0.15.12"
55
keywords = ["cli", "terminal", "colors", "console", "ansi"]
66
authors = ["Armin Ronacher <[email protected]>"]
77
license = "MIT"

src/utils.rs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -980,18 +980,29 @@ fn test_text_width() {
980980
.on_black()
981981
.bold()
982982
.force_styling(true)
983-
.to_string()
984-
+ "🐶bar";
983+
.to_string();
984+
985985
assert_eq!(
986986
measure_text_width(&s),
987+
if cfg!(feature = "ansi-parsing") {
988+
3
989+
} else if cfg!(feature = "unicode-width") {
990+
17
991+
} else {
992+
21
993+
}
994+
);
995+
996+
assert_eq!(
997+
measure_text_width(&style("🐶").red().to_string()),
987998
match (
988999
cfg!(feature = "ansi-parsing"),
9891000
cfg!(feature = "unicode-width")
9901001
) {
991-
(true, true) => 8,
992-
(true, false) => 7,
993-
(false, true) => 22,
994-
(false, false) => 25,
1002+
(true, true) => 2,
1003+
(true, false) => 1,
1004+
(false, true) => 17,
1005+
(false, false) => 1,
9951006
}
9961007
);
9971008
}
@@ -1032,6 +1043,11 @@ fn test_slice_ansi_str() {
10321043
let test_str = "Hello\x1b[31m🐶\x1b[1m🐶\x1b[0m world!";
10331044
assert_eq!(slice_str(test_str, "", 0..test_str.len(), ""), test_str);
10341045

1046+
assert_eq!(
1047+
slice_str(test_str, ">>>", 0..test_str.len(), "<<<"),
1048+
format!(">>>{test_str}<<<"),
1049+
);
1050+
10351051
if cfg!(feature = "unicode-width") && cfg!(feature = "ansi-parsing") {
10361052
assert_eq!(measure_text_width(test_str), 16);
10371053

@@ -1064,6 +1080,11 @@ fn test_slice_ansi_str() {
10641080
slice_str(test_str, "", 7..21, ""),
10651081
"\x1b[31m\x1b[1m🐶\x1b[0m world!"
10661082
);
1083+
1084+
assert_eq!(
1085+
slice_str(test_str, ">>>", 7..21, "<<<"),
1086+
"\x1b[31m>>>\x1b[1m🐶\x1b[0m world!<<<"
1087+
);
10671088
}
10681089
}
10691090

0 commit comments

Comments
 (0)