Skip to content

Commit

Permalink
Add test to ProtectedModeMemoryCore for tracking malloc exhaustion
Browse files Browse the repository at this point in the history
and switching to different segments.
  • Loading branch information
paladine committed Jan 4, 2022
1 parent 7111b63 commit 0ef2e06
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions MBBSEmu.Tests/Memory/ProtectedModeMemoryCore_Tests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MBBSEmu.DependencyInjection;
using FluentAssertions;
using MBBSEmu.DependencyInjection;
using MBBSEmu.Memory;
using NLog;
using System.Text;
Expand All @@ -24,8 +25,24 @@ public void EndOfSegmentString()

var stringFromMemory = Encoding.ASCII.GetString((memoryCore as IMemoryCore).GetString(1, testStringOffset, stripNull: false));

Assert.Equal(testString, stringFromMemory);
stringFromMemory.Should().Be(testString);
}

[Fact]
public void MultiSegmentAllocation()
{
var memoryCore = new ProtectedModeMemoryCore(_logger);
var data1 = memoryCore.Malloc(0xFF00);
data1.Should().NotBeNull();

var data2 = memoryCore.Malloc(0xFF00);
data2.Should().NotBeNull();
data2.Segment.Should().NotBe(data1.Segment);

var data3 = memoryCore.Malloc(0xFF00);
data3.Should().NotBeNull();
data3.Segment.Should().NotBe(data2.Segment);
data3.Segment.Should().NotBe(data1.Segment);
}
}
}

0 comments on commit 0ef2e06

Please sign in to comment.