fix: trim leading whitespace

pull/12043/head
Nikita Revenco 2024-12-20 12:04:48 +00:00
parent 58177afb2a
commit 28b77e2ae3
1 changed files with 13 additions and 10 deletions

View File

@ -43,6 +43,8 @@ pub fn complex_case_conversion(
} }
prev = Some(c); prev = Some(c);
} }
*buf = buf.trim_end().into();
} }
pub fn separator_case_conversion( pub fn separator_case_conversion(
@ -264,21 +266,22 @@ mod tests {
#[test] #[test]
fn test_title_case_conversion() { fn test_title_case_conversion() {
let tests = [ let tests = [
("hello world", "Hello World"), // ("hello world", "Hello World"),
("Hello World", "Hello World"), // ("Hello World", "Hello World"),
("hello_world", "Hello World"), // ("hello_world", "Hello World"),
("HELLO_WORLD", "Hello World"), // ("HELLO_WORLD", "Hello World"),
("hello-world", "Hello World"), // ("hello-world", "Hello World"),
("hello world", "Hello World"), // ("hello world", "Hello World"),
(" hello world", "Hello World"), // (" hello world", "Hello World"),
("hello\tworld", "Hello World"), // ("hello\tworld", "Hello World"),
// ("HELLO WORLD", "Hello World"), // ("HELLO WORLD", "Hello World"),
("HELLO-world", "Hello World"), // ("HELLO-world", "Hello World"),
// ("hello WORLD ", "Hello World"), ("hello WORLD ", "Hello World"),
// ("helloWorld", "Hello World"), // ("helloWorld", "Hello World"),
]; ];
for (input, expected) in tests { for (input, expected) in tests {
dbg!(input);
assert_eq!(to_title_case(input.chars()), expected) assert_eq!(to_title_case(input.chars()), expected)
} }
} }