Skip to content

Commit

Permalink
Add failing test to reproduce jbevain#859
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-englert committed Jun 16, 2022
1 parent 49b1c52 commit 1213f5d
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Test/Mono.Cecil.Tests/ImageWriteTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System.IO;
using System.Linq;
using NUnit.Framework;

namespace Mono.Cecil.Tests {
[TestFixture]
public class ImageWriteTests : BaseTestFixture {

[TestCase("EmbeddedPdbTarget.exe")]
// [TestCase("ExternalPdbDeterministic.dll")]
public void MultipleWriteOperationsShouldReturnSameOutput (string testee)
{
TestModule (testee, module => {
Assert.IsTrue (module.HasDebugHeader);
const int numberOfStreams = 5;
MemoryStream Write(int _)
{
var stream = new MemoryStream ();
module.Write (stream, new WriterParameters { WriteSymbols = true });
return stream;
}
var streams = Enumerable.Range (0, numberOfStreams)
.Select (Write)
.ToArray ();
static bool AreStreamsEqual ((MemoryStream First, MemoryStream Second) pair)
{
var buffer1 = pair.First.GetBuffer ();
var buffer2 = pair.Second.GetBuffer ();
return buffer1.SequenceEqual (buffer2);
}
var results = streams.Zip (streams.Skip (1))
.Select (AreStreamsEqual)
.ToArray ();
Assert.That (results, Is.EquivalentTo (results.Select (_ => true)));
});
}
}
}

0 comments on commit 1213f5d

Please sign in to comment.