1 use unindent::{unindent, unindent_bytes, Unindent};
2
3 #[test]
fn_unindent_str()4 fn fn_unindent_str() {
5 let s = "
6 line one
7 line two";
8 assert_eq!(unindent(s), "line one\nline two");
9
10 let s = "\n\t\t\tline one\n\t\t\tline two";
11 assert_eq!(unindent(s), "line one\nline two");
12 }
13
14 #[test]
fn_unindent_bytes()15 fn fn_unindent_bytes() {
16 let b = b"
17 line one
18 line two";
19 assert_eq!(unindent_bytes(b), b"line one\nline two");
20
21 let b = b"\n\t\t\tline one\n\t\t\tline two";
22 assert_eq!(unindent_bytes(b), b"line one\nline two");
23 }
24
25 #[test]
trait_unindent_str()26 fn trait_unindent_str() {
27 let s = "
28 line one
29 line two";
30 assert_eq!(s.unindent(), "line one\nline two");
31
32 let s = "\n\t\t\tline one\n\t\t\tline two";
33 assert_eq!(s.unindent(), "line one\nline two");
34 }
35
36 #[test]
trait_unindent_bytes()37 fn trait_unindent_bytes() {
38 let b = b"
39 line one
40 line two";
41 assert_eq!(b.unindent(), b"line one\nline two");
42
43 let b = b"\n\t\t\tline one\n\t\t\tline two";
44 assert_eq!(b.unindent(), b"line one\nline two");
45 }
46
47 #[test]
carriage_returns()48 fn carriage_returns() {
49 let s = "\r\n\tline one\r\n\tline two";
50 assert_eq!(unindent(s), "line one\r\nline two");
51 }
52