mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 04:33:37 +00:00
Additional AssetPath unit tests. (#10279)
# Objective Additional unit test for AssetPath.
This commit is contained in:
parent
65b3ff1c63
commit
cfcc113fb7
1 changed files with 39 additions and 0 deletions
|
@ -717,6 +717,36 @@ mod tests {
|
|||
assert_eq!(result, Err(crate::ParseAssetPathError::InvalidSourceSyntax));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parent() {
|
||||
// Parent consumes path segments, returns None when insufficient
|
||||
let result = AssetPath::from("a/b.test");
|
||||
assert_eq!(result.parent(), Some(AssetPath::from("a")));
|
||||
assert_eq!(result.parent().unwrap().parent(), Some(AssetPath::from("")));
|
||||
assert_eq!(result.parent().unwrap().parent().unwrap().parent(), None);
|
||||
|
||||
// Parent cannot consume asset source
|
||||
let result = AssetPath::from("http://a");
|
||||
assert_eq!(result.parent(), Some(AssetPath::from("http://")));
|
||||
assert_eq!(result.parent().unwrap().parent(), None);
|
||||
|
||||
// Parent consumes labels
|
||||
let result = AssetPath::from("http://a#Foo");
|
||||
assert_eq!(result.parent(), Some(AssetPath::from("http://")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_with_source() {
|
||||
let result = AssetPath::from("http://a#Foo");
|
||||
assert_eq!(result.with_source("ftp"), AssetPath::from("ftp://a#Foo"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_without_label() {
|
||||
let result = AssetPath::from("http://a#Foo");
|
||||
assert_eq!(result.without_label(), AssetPath::from("http://a"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_resolve_full() {
|
||||
// A "full" path should ignore the base path.
|
||||
|
@ -966,4 +996,13 @@ mod tests {
|
|||
AssetPath::from("../joe/next")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_extension() {
|
||||
let result = AssetPath::from("http://a.tar.gz#Foo");
|
||||
assert_eq!(result.get_full_extension(), Some("tar.gz".to_string()));
|
||||
|
||||
let result = AssetPath::from("http://a#Foo");
|
||||
assert_eq!(result.get_full_extension(), None);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue