Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_reflect/src/impls/std/mod.rs
6600 views
1
mod collections;
2
mod ffi;
3
mod path;
4
5
#[cfg(test)]
6
mod tests {
7
use crate::{FromReflect, PartialReflect};
8
use std::collections::HashMap;
9
use std::path::Path;
10
11
#[test]
12
fn should_partial_eq_hash_map() {
13
let mut a = <HashMap<_, _>>::default();
14
a.insert(0usize, 1.23_f64);
15
let b = a.clone();
16
let mut c = <HashMap<_, _>>::default();
17
c.insert(0usize, 3.21_f64);
18
19
let a: &dyn PartialReflect = &a;
20
let b: &dyn PartialReflect = &b;
21
let c: &dyn PartialReflect = &c;
22
assert!(a.reflect_partial_eq(b).unwrap_or_default());
23
assert!(!a.reflect_partial_eq(c).unwrap_or_default());
24
}
25
26
#[test]
27
fn path_should_from_reflect() {
28
let path = Path::new("hello_world.rs");
29
let output = <&'static Path as FromReflect>::from_reflect(&path).unwrap();
30
assert_eq!(path, output);
31
}
32
33
#[test]
34
fn type_id_should_from_reflect() {
35
let type_id = core::any::TypeId::of::<usize>();
36
let output = <core::any::TypeId as FromReflect>::from_reflect(&type_id).unwrap();
37
assert_eq!(type_id, output);
38
}
39
40
#[test]
41
fn static_str_should_from_reflect() {
42
let expected = "Hello, World!";
43
let output = <&'static str as FromReflect>::from_reflect(&expected).unwrap();
44
assert_eq!(expected, output);
45
}
46
}
47
48