Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiburt committed Feb 2, 2025
1 parent 3a97e15 commit c626868
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
4 changes: 2 additions & 2 deletions tabled/src/settings/span/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Span {
/// * == 1 - which is a default span so can be used for removal of spans
/// * > 1 - which means to spread a cell by given number of columns right
/// * < 0 - which means to spread a cell by given number of columns left
///
///
/// # Example
///
/// ```
Expand Down Expand Up @@ -93,7 +93,7 @@ impl Span {
/// * == 1 - which is a default span so can be used for removal of spans
/// * > 1 - which means to spread a cell by given number of rows bottom
/// * < 0 - which means to spread a cell by given number of rows top
///
///
/// # Example
///
/// ```
Expand Down
30 changes: 12 additions & 18 deletions tabled/src/util/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,42 +233,36 @@ mod tests {
fn strip_color_test() {
let numbers = "\u{1b}[31;100m123456\u{1b}[39m\u{1b}[49m";

assert_eq!(cut_str(&numbers, 0), "\u{1b}[31;100m\u{1b}[39m\u{1b}[49m");
assert_eq!(cut_str(numbers, 0), "\u{1b}[31;100m\u{1b}[39m\u{1b}[49m");
assert_eq!(cut_str(numbers, 3), "\u{1b}[31;100m123\u{1b}[39m\u{1b}[49m");
assert_eq!(
cut_str(&numbers, 3),
"\u{1b}[31;100m123\u{1b}[39m\u{1b}[49m"
);
assert_eq!(
cut_str(&numbers, 10),
cut_str(numbers, 10),
"\u{1b}[31;100m123456\u{1b}[39m\u{1b}[49m"
);

let emojies = "\u{1b}[31;100m😳😳😳😳😳\u{1b}[39m\u{1b}[49m";

assert_eq!(cut_str(&emojies, 0), "\u{1b}[31;100m\u{1b}[39m\u{1b}[49m");
assert_eq!(
cut_str(&emojies, 3),
"\u{1b}[31;100m😳\u{1b}[39m\u{1b}[49m�"
);
assert_eq!(cut_str(emojies, 0), "\u{1b}[31;100m\u{1b}[39m\u{1b}[49m");
assert_eq!(cut_str(emojies, 3), "\u{1b}[31;100m😳\u{1b}[39m\u{1b}[49m�");
assert_eq!(
cut_str(&emojies, 4),
cut_str(emojies, 4),
"\u{1b}[31;100m😳😳\u{1b}[39m\u{1b}[49m"
);
assert_eq!(
cut_str(&emojies, 20),
cut_str(emojies, 20),
"\u{1b}[31;100m😳😳😳😳😳\u{1b}[39m\u{1b}[49m"
);

let emojies = "\u{1b}[31;100m🏳️🏳️\u{1b}[39m\u{1b}[49m";

assert_eq!(cut_str(&emojies, 0), "\u{1b}[31;100m\u{1b}[39m\u{1b}[49m");
assert_eq!(cut_str(&emojies, 1), "\u{1b}[31;100m🏳\u{1b}[39m\u{1b}[49m");
assert_eq!(cut_str(emojies, 0), "\u{1b}[31;100m\u{1b}[39m\u{1b}[49m");
assert_eq!(cut_str(emojies, 1), "\u{1b}[31;100m🏳\u{1b}[39m\u{1b}[49m");
assert_eq!(
cut_str(&emojies, 2),
cut_str(emojies, 2),
"\u{1b}[31;100m🏳\u{fe0f}🏳\u{1b}[39m\u{1b}[49m"
);
assert_eq!(
get_line_width(&emojies),
get_line_width(emojies),
get_line_width("\u{1b}[31;100m🏳\u{fe0f}🏳\u{fe0f}\u{1b}[39m\u{1b}[49m")
);
}
Expand All @@ -278,7 +272,7 @@ mod tests {
fn test_color_strip() {
let s = "\u{1b}[5;33;48;2;12;200;100mCollored string\u{1b}[0m";
assert_eq!(
cut_str(&s, 1),
cut_str(s, 1),
"\u{1b}[5;33;48;2;12;200;100mC\u{1b}[25m\u{1b}[39m\u{1b}[49m"
)
}
Expand Down

0 comments on commit c626868

Please sign in to comment.