-
Notifications
You must be signed in to change notification settings - Fork 84
/
interpolated_path.rs
37 lines (33 loc) · 932 Bytes
/
interpolated_path.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
use rust_embed::RustEmbed;
/// Test doc comment
#[derive(RustEmbed)]
#[folder = "$CARGO_MANIFEST_DIR/examples/public/"]
struct Asset;
#[test]
fn get_works() {
assert!(Asset::get("index.html").is_some(), "index.html should exist");
assert!(Asset::get("gg.html").is_none(), "gg.html should not exist");
assert!(Asset::get("images/llama.png").is_some(), "llama.png should exist");
}
#[test]
fn iter_works() {
let mut num_files = 0;
for file in Asset::iter() {
assert!(Asset::get(file.as_ref()).is_some());
num_files += 1;
}
assert_eq!(num_files, 7);
}
#[test]
fn trait_works_generic() {
trait_works_generic_helper::<Asset>();
}
fn trait_works_generic_helper<E: rust_embed::RustEmbed>() {
let mut num_files = 0;
for file in E::iter() {
assert!(E::get(file.as_ref()).is_some());
num_files += 1;
}
assert_eq!(num_files, 7);
assert!(E::get("gg.html").is_none(), "gg.html should not exist");
}