Skip to content

Commit

Permalink
Corrected problem with memory tests found by recent chanages
Browse files Browse the repository at this point in the history
  • Loading branch information
dahall committed Aug 27, 2019
1 parent 26c4f6d commit d2cb04c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions UnitTests/Core/InteropServices/SafeCoTaskMemHandleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ public void CreateFromListTest()
Assert.That(h.ToStructure<int>(), Is.EqualTo(5));
Assert.That(h.ToEnumerable<int>(4), Has.Exactly(4).EqualTo(5).And.Exactly(4).Items);

var d = new[] { new RECT(1,1,1,1), new RECT(2,2,2,2) };
var d = new[] { new RECT(1, 1, 1, 1), new RECT(2, 2, 2, 2) };
h = SafeCoTaskMemHandle.CreateFromList(d, d.Length);
Assert.That(!h.IsClosed && !h.IsInvalid);
Assert.That((int)h.Size, Is.EqualTo(Marshal.SizeOf(typeof(RECT)) * d.Length));
Assert.That(h.ToStructure<RECT>().X, Is.EqualTo(1));
Assert.That(h.ToArray<RECT>(4), Has.Exactly(4).Items);
Assert.That(h.ToArray<RECT>(2), Has.Exactly(2).Items);

var p = new[] { new PRECT(1,1,1,1), new PRECT(2,2,2,2) };
var p = new[] { new PRECT(1, 1, 1, 1), new PRECT(2, 2, 2, 2) };
h = SafeCoTaskMemHandle.CreateFromList(p);
Assert.That(!h.IsClosed && !h.IsInvalid);
Assert.That((int)h.Size, Is.EqualTo(Marshal.SizeOf(typeof(PRECT)) * p.Length));
Assert.That(h.ToArray<RECT>(4), Has.Exactly(4).Items);
Assert.That(h.ToArray<RECT>(2), Has.Exactly(2).Items);

Assert.That(() => SafeCoTaskMemHandle.CreateFromList(new[] {"X"}), Throws.ArgumentException);
Assert.That(() => SafeCoTaskMemHandle.CreateFromList(new[] { "X" }), Throws.ArgumentException);
}

[Test(Description = "Allocate an enumeration of strings.")]
Expand Down
4 changes: 2 additions & 2 deletions UnitTests/Core/InteropServices/SafeHGlobalHandleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public void CreateFromListTest()
Assert.That(!h.IsClosed && !h.IsInvalid);
Assert.That((int)h.Size, Is.EqualTo(Marshal.SizeOf(typeof(RECT)) * d.Length));
Assert.That(h.ToStructure<RECT>().X, Is.EqualTo(1));
Assert.That(h.ToArray<RECT>(4), Has.Exactly(4).Items);
Assert.That(h.ToArray<RECT>(2), Has.Exactly(2).Items);

var p = new[] { new PRECT(1, 1, 1, 1), new PRECT(2, 2, 2, 2) };
h = SafeHGlobalHandle.CreateFromList(p);
Assert.That(!h.IsClosed && !h.IsInvalid);
Assert.That((int)h.Size, Is.EqualTo(Marshal.SizeOf(typeof(PRECT)) * p.Length));
Assert.That(h.ToArray<RECT>(4), Has.Exactly(4).Items);
Assert.That(h.ToArray<RECT>(2), Has.Exactly(2).Items);

Assert.That(() => SafeHGlobalHandle.CreateFromList(new[] { "X" }), Throws.ArgumentException);
}
Expand Down

0 comments on commit d2cb04c

Please sign in to comment.