forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.rs
64 lines (55 loc) · 1.51 KB
/
tests.rs
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
use super::*;
fn t(builder: UrlPartsBuilder, expect: &str) {
assert_eq!(builder.finish(), expect);
}
#[test]
fn empty() {
t(UrlPartsBuilder::new(), "");
}
#[test]
fn singleton() {
t(UrlPartsBuilder::singleton("index.html"), "index.html");
}
#[test]
fn push_several() {
let mut builder = UrlPartsBuilder::new();
builder.push("core");
builder.push("str");
builder.push("struct.Bytes.html");
t(builder, "core/str/struct.Bytes.html");
}
#[test]
fn push_front_empty() {
let mut builder = UrlPartsBuilder::new();
builder.push_front("page.html");
t(builder, "page.html");
}
#[test]
fn push_front_non_empty() {
let mut builder = UrlPartsBuilder::new();
builder.push("core");
builder.push("str");
builder.push("struct.Bytes.html");
builder.push_front("nightly");
t(builder, "nightly/core/str/struct.Bytes.html");
}
#[test]
fn push_fmt() {
let mut builder = UrlPartsBuilder::new();
builder.push_fmt(format_args!("{}", "core"));
builder.push("str");
builder.push_front("nightly");
builder.push_fmt(format_args!("{}.{}.html", "struct", "Bytes"));
t(builder, "nightly/core/str/struct.Bytes.html");
}
#[test]
fn collect() {
t(["core", "str"].into_iter().collect(), "core/str");
t(["core", "str", "struct.Bytes.html"].into_iter().collect(), "core/str/struct.Bytes.html");
}
#[test]
fn extend() {
let mut builder = UrlPartsBuilder::singleton("core");
builder.extend(["str", "struct.Bytes.html"]);
t(builder, "core/str/struct.Bytes.html");
}