aboutsummaryrefslogtreecommitdiff
path: root/stockton-types/tests/world.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-25 17:44:19 +0100
committertcmal <me@aria.rip>2024-08-25 17:44:19 +0100
commitb2fbd5116b66a3560639bdcbad914c52b43e878e (patch)
treea6d9e2883810a40e0b5b547018e7bf966a5a117c /stockton-types/tests/world.rs
parent3f8cef9bbbc58aff9045d1b7d729313384b8ae89 (diff)
feat(types): add macro for generating entity mappers
Diffstat (limited to 'stockton-types/tests/world.rs')
-rw-r--r--stockton-types/tests/world.rs90
1 files changed, 21 insertions, 69 deletions
diff --git a/stockton-types/tests/world.rs b/stockton-types/tests/world.rs
index 4ad68ea..83bb178 100644
--- a/stockton-types/tests/world.rs
+++ b/stockton-types/tests/world.rs
@@ -16,27 +16,14 @@
extern crate stockton_types;
extern crate stockton_bsp;
-use stockton_bsp::BSPFile;
-use stockton_bsp::lumps::*;
+#[macro_use]
+mod helpers;
+use crate::helpers::*;
+
use stockton_bsp::lumps::entities::Entity as BSPEntity;
-use stockton_bsp::directory::{DirEntry, Header};
use stockton_types::{World, Entity, Vector3};
-
-macro_rules! map(
- { $($key:expr => $value:expr),+ } => {
- {
- let mut m = ::std::collections::HashMap::new();
- $(
- m.insert($key, $value);
- )+
- m
- }
- };
-);
-
-
#[derive(Debug, PartialEq)]
struct DummyEntity;
@@ -50,58 +37,23 @@ impl Entity for DummyEntity {
#[test]
fn world_creation() {
- let file = Box::pin(BSPFile {
- directory: Header {
- version: 1,
- dir_entries: [DirEntry { offset: 0, length: 0 }; 17]
- },
- entities: EntitiesLump {
- string: "dummy",
- entities: vec![
- BSPEntity {
- attributes: map!(
- "name" => "1"
- )
- },
- BSPEntity {
- attributes: map!(
- "name" => "2"
- )
- },
- BSPEntity {
- attributes: map!(
- "name" => "3"
- )
- }
- ]
- },
- textures: TexturesLump {
- textures: vec![].into_boxed_slice()
- },
- planes: PlanesLump {
- planes: vec![].into_boxed_slice()
- },
- lightvols: LightVolsLump {
- vols: vec![].into_boxed_slice()
- },
- lightmaps: LightmapsLump {
- maps: vec![].into_boxed_slice()
- },
- meshverts: MeshVertsLump {
- meshverts: vec![].into_boxed_slice()
- },
- vertices: VerticesLump {
- vertices: vec![].into_boxed_slice()
- },
- effects: EffectsLump::empty(),
- brushes: BrushesLump::empty(),
- faces: FaceLump::empty(),
- tree: BSPTree::empty(),
- visdata: VisDataLump {
- vecs: vec![].into_boxed_slice()
- },
- models: ModelsLump::empty()
- });
+ let file = dummy_bspfile(vec![
+ BSPEntity {
+ attributes: map!(
+ "name" => "1"
+ )
+ },
+ BSPEntity {
+ attributes: map!(
+ "name" => "2"
+ )
+ },
+ BSPEntity {
+ attributes: map!(
+ "name" => "3"
+ )
+ }
+ ]);
let mut called_times = 0;