granite-rust/src/libcore/tests/intrinsics.rs

21 lines
523 B
Rust
Raw Normal View History

use core::any::TypeId;
#[test]
fn test_typeid_sized_types() {
2015-10-15 21:07:20 +02:00
struct X; struct Y(u32);
assert_eq!(TypeId::of::<X>(), TypeId::of::<X>());
assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());
assert!(TypeId::of::<X>() != TypeId::of::<Y>());
}
#[test]
fn test_typeid_unsized_types() {
trait Z {}
2018-07-13 14:25:22 +09:00
struct X(str); struct Y(dyn Z + 'static);
assert_eq!(TypeId::of::<X>(), TypeId::of::<X>());
assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());
assert!(TypeId::of::<X>() != TypeId::of::<Y>());
}