mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.7 KiB
56 lines
1.7 KiB
// --------------------------------------------------------------------------------------------------------------------
|
|
// <copyright file="DoubleExtensionsUnitTests.cs" company="James South">
|
|
// Copyright (c) James South.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
// </copyright>
|
|
// <summary>
|
|
// Runs unit tests on the <see cref="DoubleExtensions" /> extension methods
|
|
// </summary>
|
|
// --------------------------------------------------------------------------------------------------------------------
|
|
|
|
namespace ImageProcessor.UnitTests.Extensions
|
|
{
|
|
using System.Collections.Generic;
|
|
using Common.Extensions;
|
|
using NUnit.Framework;
|
|
|
|
/// <summary>
|
|
/// Test harness for the DoubleExtensions extension methods
|
|
/// </summary>
|
|
[TestFixture]
|
|
public class DoubleExtensionsUnitTests
|
|
{
|
|
/// <summary>
|
|
/// Stores the values to test for the ToByte() extension method
|
|
/// </summary>
|
|
private Dictionary<double, byte> doubleToByteTests;
|
|
|
|
/// <summary>
|
|
/// Sets up the values for the tests
|
|
/// </summary>
|
|
[TestFixtureSetUp]
|
|
public void Init()
|
|
{
|
|
this.doubleToByteTests = new Dictionary<double, byte>
|
|
{
|
|
{ -10, 0x0 },
|
|
{ 1.5, 0x1 },
|
|
{ 25.7, 0x19 },
|
|
{ 1289047, 0xFF }
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tests the double to byte conversion
|
|
/// </summary>
|
|
[Test]
|
|
public void TestDoubleToByte()
|
|
{
|
|
foreach (var item in this.doubleToByteTests)
|
|
{
|
|
var result = item.Key.ToByte();
|
|
Assert.AreEqual(item.Value, result);
|
|
}
|
|
}
|
|
}
|
|
}
|