Mercurial > repos > IBBoard.Tests
view Lang/IBBMathTests.cs @ 0:7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 17 May 2009 16:09:38 +0000 |
parents | |
children | 80c42a1101a8 |
line wrap: on
line source
// This file (IBBMathTest.cs) is a part of the IBBoard.Tests project and is copyright 2009 IBBoard // // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. // using System; using NUnit.Framework; namespace IBBoard.Lang { [TestFixture()] public class IBBMathTest { [Test()] public void TestRoundHalfPerformsBankersRoundingBelowLowMidpoint() { Assert.AreEqual(3, IBBMath.RoundToHalf(3.2)); } [Test()] public void TestRoundHalfPerformsBankersRoundingJustBelowLowMidpoint() { Assert.AreEqual(3, IBBMath.RoundToHalf(3.24)); } [Test()] public void TestRoundHalfPerformsBankersRoundingOnLowMidpoint() { Assert.AreEqual(3, IBBMath.RoundToHalf(3.25)); } [Test()] public void TestRoundHalfPerformsBankersRoundingJustAboveLowMidpoint() { Assert.AreEqual(3.5, IBBMath.RoundToHalf(3.26)); } [Test()] public void TestRoundHalfPerformsBankersRoundingAboveLowMidpoint() { Assert.AreEqual(3.5, IBBMath.RoundToHalf(3.3)); } [Test()] public void TestRoundHalfPerformsBankersRoundingBelowHighMidpoint() { Assert.AreEqual(3.5, IBBMath.RoundToHalf(3.7)); } [Test()] public void TestRoundHalfPerformsBankersRoundingJustBelowHighMidpoint() { Assert.AreEqual(3.5, IBBMath.RoundToHalf(3.74)); } [Test()] public void TestRoundHalfPerformsBankersRoundingOnHighMidpoint() { Assert.AreEqual(4, IBBMath.RoundToHalf(3.75)); } [Test()] public void TestRoundHalfPerformsBankersRoundingJustAboveHighMidpoint() { Assert.AreEqual(4, IBBMath.RoundToHalf(3.76)); } [Test()] public void TestRoundHalfPerformsBankersRoundingAboveHighMidpoint() { Assert.AreEqual(4, IBBMath.RoundToHalf(3.8)); } [Test()] public void TestRoundHalfDoesntRoundHalf() { Assert.AreEqual(3.5, IBBMath.RoundToHalf(3.5)); } [Test()] public void TestRoundHalfDoesntRoundEvenNumber() { Assert.AreEqual(4, IBBMath.RoundToHalf(4)); } [Test()] public void TestRoundHalfDoesntRoundOddNumber() { Assert.AreEqual(3, IBBMath.RoundToHalf(3)); } } }