First iteration that should work correctly but seems to have some memory issues with entities

This commit is contained in:
Lol3rrr
2024-10-17 21:15:03 +02:00
parent 840ac071b1
commit 14c422983e
15 changed files with 735 additions and 18 deletions

51
tests/lazy.rs Normal file
View File

@@ -0,0 +1,51 @@
#[test]
fn cmp_lazy_nonlazy_events() {
let content = std::fs::read("testfiles/mirage.dem").unwrap();
let container = csdemo::Container::parse(&content).unwrap();
let demo = csdemo::parser::parse(
csdemo::FrameIterator::parse(container.inner),
csdemo::parser::EntityFilter::disabled(),
)
.unwrap();
let lazy_demo =
csdemo::lazyparser::LazyParser::new(csdemo::Container::parse(&content).unwrap());
for (normal, lazied) in demo
.events
.into_iter()
.zip(lazy_demo.events().filter_map(|e| e.ok()))
{
assert_eq!(normal, lazied);
}
}
#[test]
fn cmp_lazy_nonlazy_entities() {
let content = std::fs::read("testfiles/mirage.dem").unwrap();
let container = csdemo::Container::parse(&content).unwrap();
let demo = csdemo::parser::parse(
csdemo::FrameIterator::parse(container.inner),
csdemo::parser::EntityFilter::all(),
)
.unwrap();
let lazy_demo =
csdemo::lazyparser::LazyParser::new(csdemo::Container::parse(&content).unwrap());
let mut normal_iter = demo
.entity_states
.ticks
.into_iter()
.flat_map(|t| t.states.into_iter().map(move |s| (t.tick, s)));
let mut lazy_iter = lazy_demo.entities().filter_map(|e| e.ok());
while let Some(normal) = normal_iter.next() {
let lazy = lazy_iter.next().unwrap();
assert_eq!(normal, lazy);
}
assert_eq!(None, lazy_iter.next());
}