-
-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved performance of the ToByteArray methods (#1447)
- Loading branch information
Showing
9 changed files
with
113 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
tests/Magick.NET.Tests/Helpers/ByteArrayWrapperTests/TheDisposeMethod.cs
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
tests/Magick.NET.Tests/Helpers/ByteArrayWrapperTests/TheGetBytesMethod.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
using System; | ||
using System.IO; | ||
using ImageMagick; | ||
using Xunit; | ||
|
||
namespace Magick.NET.Tests; | ||
|
||
public partial class ByteArrayWrapperTests | ||
{ | ||
public class TheGetBytesMethod | ||
{ | ||
[Fact] | ||
public unsafe void ShouldOnlyReturnTheWrittenBytes() | ||
{ | ||
var wrapper = new ByteArrayWrapper(); | ||
wrapper.Seek(42, (IntPtr)SeekOrigin.Current, IntPtr.Zero); | ||
wrapper.Seek(0, (IntPtr)SeekOrigin.Begin, IntPtr.Zero); | ||
|
||
var buffer = new byte[5]; | ||
fixed (byte* p = buffer) | ||
{ | ||
wrapper.Write((IntPtr)p, (UIntPtr)3, IntPtr.Zero); | ||
} | ||
|
||
var bytes = wrapper.GetBytes(); | ||
Assert.Equal(3, bytes.Length); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.