Skip to content

Commit

Permalink
chore: update tests, update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Gounlaf committed Mar 7, 2024
1 parent 85c2d2a commit 472346a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/Magick.NET.Core/Types/Percentage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace ImageMagick;
/// <summary>
/// Initializes a new instance of the <see cref="Percentage"/> struct.
/// </summary>
/// <param name="value">The value (0% = 0.0, 100% = 100.0).</param>
/// <param name="value">The value (0% = 0.0, 100% = 100.0, 142.42% = 142.42).</param>
public Percentage(double value)
{
Throw.IfNegative(nameof(value), value);
Expand All @@ -27,7 +27,7 @@ public Percentage(double value)
/// <summary>
/// Initializes a new instance of the <see cref="Percentage"/> struct.
/// </summary>
/// <param name="value">The value (0% = 0, 100% = 100).</param>
/// <param name="value">The value (0% = 0, 100% = 100, 142% = 142).</param>
public Percentage(int value)
{
Throw.IfNegative(nameof(value), value);
Expand All @@ -38,14 +38,14 @@ public Percentage(int value)
/// <summary>
/// Converts the specified double to an instance of this type.
/// </summary>
/// <param name="value">The value (0% = 0, 100% = 100).</param>
/// <param name="value">The value (0% = 0.0, 100% = 100.0, 142.42% = 142.42).</param>
public static explicit operator Percentage(double value)
=> new Percentage(value);

/// <summary>
/// Converts the specified int to an instance of this type.
/// </summary>
/// <param name="value">The value (0% = 0, 100% = 100).</param>
/// <param name="value">The value (0% = 0, 100% = 100, 142% = 142).</param>
public static explicit operator Percentage(int value)
=> new Percentage(value);

Expand Down
6 changes: 1 addition & 5 deletions src/Magick.NET/ResourceLimits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,7 @@ ulong IResourceLimits.Width
/// </summary>
/// <param name="percentage">The percentage to use.</param>
public static void LimitMemory(Percentage percentage)
{
Throw.IfOutOfRange(nameof(percentage), percentage);

NativeResourceLimits.LimitMemory((double)percentage / 100.0);
}
=> NativeResourceLimits.LimitMemory((double)percentage / 100.0);

/// <summary>
/// Set the maximum percentage of memory that can be used for image data. This also changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ public partial class ResourceLimitsTests
[Collection(nameof(RunTestsSeparately))]
public class TheLimitMemoryMethod
{
[Fact]
public void ShouldThrowExceptionWhenValueIsTooHigh()
{
Assert.Throws<ArgumentOutOfRangeException>("percentage", () => ResourceLimits.LimitMemory(new Percentage(100.1)));
}

[Fact]
public void ShouldChangeAreaAndMemory()
{
Expand Down

0 comments on commit 472346a

Please sign in to comment.