Skip to content

Commit 10bc892

Browse files
committed
Fix tests in RELEASE build
1 parent ed4ba41 commit 10bc892

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

MetadataProcessor.Tests/Core/Mono.Cecil/CodeWriterTests.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,11 @@ public void PreProcessMethodIntegrationTest()
163163
// test
164164
var r = CodeWriter.PreProcessMethod(methodDefinition, nanoTablesContext.StringTable).ToArray();
165165

166+
#if DEBUG
166167
Assert.AreEqual("[18,16][24,20][31,25]", String.Join(String.Empty, r.Select(i=>$"[{i.Item1.ToString()},{i.Item2.ToString()}]")));
168+
#else
169+
Assert.AreEqual("[14,12][20,16][27,21]", String.Join(String.Empty, r.Select(i=>$"[{i.Item1.ToString()},{i.Item2.ToString()}]")));
170+
#endif
167171

168172
Assert.IsTrue(nanoTablesContext.StringTable.GetItems().ContainsKey("blabla"));
169173
}
@@ -425,12 +429,11 @@ public void WriteMethodBodyIntegrationTest()
425429
});
426430

427431

432+
#if DEBUG
428433
var expectedBytesWritten = new byte[] { 0x00, 0x16, 0x0A, 0x00, 0x03, 0x04, 0x58, 0x0A, 0x00, 0xDE, 0x18, 0x0B, 0x00, 0x72, 0x50, 0x01, 0x07, 0x73, 0x0D, 0x80, 0x0C, 0x08, 0x6F, 0x0E, 0x80, 0x0A, 0x00, 0xDE, 0x00, 0x06, 0x0D, 0x2B, 0x00, 0x09, 0x2A, 0x00, 0x00, 0x11, 0x80, 0x03, 0x00, 0x0B, 0x00, 0x0B, 0x00, 0x23, 0x00, 0x01 };
429-
if (!nanoTablesContext.AssemblyDefinition.CustomAttributes.Any(i=>i.AttributeType.FullName == "System.Diagnostics.DebuggableAttribute"))
430-
{
431-
// we are in release mode, NOPs are missing
432-
expectedBytesWritten = new byte[] { 0x16, 0x0A, 0x03, 0x04, 0x58, 0x0A, 0xDE, 0x14, 0x0B, 0x72, 0x1E-01, 0x07, 0x73, 0x0C, 0x80, 0x6F, 0x0D, 0x80, 0x0A, 0xDE, 0x00, 0x06, 0x2A, 0x00, 0x00, 0x0F, 0x80, 0x02, 0x00, 0x08, 0x00, 0x08, 0x00, 0x1C, 0x00, 0x01 };
433-
}
434+
#else
435+
var expectedBytesWritten = new byte[] { 0x16, 0x0A, 0x03, 0x04, 0x58, 0x0A, 0xDE, 0x16, 0x0B, 0x72, 0x1E, 0x01, 0x07, 0x73, 0x0C, 0x80, 0x0C, 0x08, 0x6F, 0x0D, 0x80, 0x0A, 0xDE, 0x00, 0x06, 0x2A, 0x00, 0x00, 0x0F, 0x80, 0x02, 0x00, 0x08, 0x00, 0x08, 0x00, 0x1E, 0x00, 0x01 };
436+
#endif
434437

435438
CollectionAssert.AreEqual(expectedBytesWritten, bytesWritten, BitConverter.ToString(bytesWritten));
436439
}

0 commit comments

Comments
 (0)