Add Component to Entity / Relation conversion tests

main
copygirl 2 months ago
parent 4663d46bee
commit 5343355a46
  1. 24
      src/ecs/component.rs

@ -135,3 +135,27 @@ impl Flags {
value | flags.bits() value | flags.bits()
} }
} }
#[cfg(test)]
mod tests {
use super::*;
use super::super::entity::Entity;
use super::super::relation::Relation;
#[test]
fn component_from_and_to_entity() {
let entity = Entity::new_checked(1337, 42).unwrap();
let component: Component = entity.into();
assert!(component.is_entity());
assert_eq!(entity, component.try_into().unwrap());
}
#[test]
fn component_from_and_to_relation() {
let relation = Relation::new_checked(20, 21).unwrap();
let component: Component = relation.into();
assert!(component.is_relation());
assert_eq!(relation, component.try_into().unwrap());
}
}

Loading…
Cancel
Save