1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
use indoc::formatdoc;
#[test]
fn carriage_return() {
// Every line in the string ends with \r\n
let indoc = formatdoc! {"
{}
\\{}
{}",
'a', 'b', 'c'
};
let expected = "a\n\n \\b\nc";
assert_eq!(indoc, expected);
}
#[test]
fn empty_string() {
let indoc = formatdoc! {""};
let expected = "";
assert_eq!(indoc, expected);
}
#[test]
fn joined_first_line() {
let indoc = formatdoc! {"\
{}", 'a'
};
let expected = "a";
assert_eq!(indoc, expected);
}
#[test]
fn joined_lines() {
let indoc = formatdoc! {"
{}\
{}
{}\
{}
{}",
'a', 'b', 'c', 'd', 'e'
};
let expected = "ab\ncd\ne";
assert_eq!(indoc, expected);
}
#[test]
fn no_leading_newline() {
let indoc = formatdoc! {"{}
{}
{}", 'a', 'b', 'c'};
let expected = "a\nb\nc";
assert_eq!(indoc, expected);
}
#[test]
fn one_line() {
let indoc = formatdoc! {"a"};
let expected = "a";
assert_eq!(indoc, expected);
}
#[test]
fn raw_string() {
let indoc = formatdoc! {r#"
{:?}
\\{}
{}"#,
"a", 'b', 'c'
};
let expected = "\"a\"\n\n \\\\b\nc";
assert_eq!(indoc, expected);
}
#[test]
fn string() {
let indoc = formatdoc! {"
{}
\\{}
{}",
'a', 'b', 'c'
};
let expected = "a\n\n \\b\nc";
assert_eq!(indoc, expected);
}
#[test]
fn string_trailing_newline() {
let indoc = formatdoc! {"
{}
\\{}
{}
",
'a', 'b', 'c'
};
let expected = "a\n\n \\b\nc\n";
assert_eq!(indoc, expected);
}
#[test]
fn trailing_whitespace() {
let indoc = formatdoc! {"
{} {below}
{} {below}
{} {below}
end",
2, 0, -2, below = "below"
};
let expected = "2 below\n \n0 below\n\n-2 below\n\nend";
assert_eq!(indoc, expected);
}
|