Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failing test to reproduce #859 #860

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Test/Mono.Cecil.Tests/ImageWriteTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.IO;
using System.Linq;
using NUnit.Framework;

#if NETCOREAPP

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)));
});
}
}
}

#endif