Skip to content

Commit

Permalink
zzio: Fix RWBS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Helco committed Jan 21, 2024
1 parent ac90b67 commit 5b317b3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Binary file modified zzio.tests/resources/rwbs_sample.dff
Binary file not shown.
16 changes: 9 additions & 7 deletions zzio.tests/zzio/rwbs/basic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private void testSection(Section section)
RWFrameList frameList = (RWFrameList)clump.children[0];
Assert.AreSame(clump, frameList.parent);
Assert.AreEqual(SectionId.FrameList, frameList.sectionId);
Assert.AreEqual(0, frameList.children.Count);
Assert.AreEqual(1, frameList.children.Count);
Assert.AreEqual(1, frameList.frames.Length);
Frame frame = frameList.frames[0];
Assert.AreEqual(0, frame.creationFlags);
Expand All @@ -41,17 +41,19 @@ private void testSection(Section section)
Assert.AreEqual(0.0f, frame.position.Y);
Assert.AreEqual(0.0f, frame.position.Z);

Assert.IsInstanceOf(typeof(RWExtension), clump.children[1]);
RWExtension extension = (RWExtension)clump.children[1];
Assert.AreSame(clump, extension.parent);
Assert.AreEqual(0, extension.children.Count);
Assert.IsInstanceOf(typeof(RWExtension), frameList.children[0]);

Assert.IsInstanceOf(typeof(RWGeometryList), clump.children[2]);
RWGeometryList geoList = (RWGeometryList)clump.children[2];
Assert.IsInstanceOf(typeof(RWGeometryList), clump.children[1]);
RWGeometryList geoList = (RWGeometryList)clump.children[1];
Assert.AreSame(clump, geoList.parent);
Assert.AreEqual(SectionId.GeometryList, geoList.sectionId);
Assert.AreEqual(0, geoList.children.Count);
Assert.AreEqual(0, geoList.geometryCount);

Assert.IsInstanceOf(typeof(RWExtension), clump.children[2]);
RWExtension extension = (RWExtension)clump.children[2];
Assert.AreSame(clump, extension.parent);
Assert.AreEqual(0, extension.children.Count);
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion zzio/rwbs/ListSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected override void readBody(Stream stream)
children.Clear();
long streamLength = stream.Length;
// there might be padding bytes, check if a header would fit
while (streamLength - stream.Position > 12)
while (streamLength - stream.Position >= 12)
{
children.Add(ReadNew(new GatekeeperStream(stream), this));
}
Expand Down

0 comments on commit 5b317b3

Please sign in to comment.