view CustomMath/IBBMathTests.cs @ 2:83d1e27d792d

* Move IBBMath tests to match namespace move in main project no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Tue, 06 Oct 2009 18:31:37 +0000
parents Lang/IBBMathTests.cs@80c42a1101a8
children 8c45831988c3
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 TestRoundHalfDoesntAlterHalf()
		{
			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));
		}
		
		[Test()]
		public void TestRoundHalfRoundsUpBelowLowMidpoint()
		{
			Assert.AreEqual(3.5, IBBMath.CeilToHalf(3.2));
		}
		
		[Test()]
		public void TestRoundHalfRoundsUpJustBelowLowMidpoint()
		{
			Assert.AreEqual(3.5, IBBMath.CeilToHalf(3.24));
		}
		
		[Test()]
		public void TestRoundHalfRoundsUpOnLowMidpoint()
		{
			Assert.AreEqual(3.5, IBBMath.CeilToHalf(3.25));
		}

		[Test()]
		public void TestRoundHalfRoundsUpJustAboveLowMidpoint()
		{
			Assert.AreEqual(3.5, IBBMath.CeilToHalf(3.26));
		}
		
		[Test()]
		public void TestRoundHalfRoundsUpAboveLowMidpoint()
		{
			Assert.AreEqual(3.5, IBBMath.CeilToHalf(3.3));
		}
		
		[Test()]
		public void TestRoundHalfRoundsUpBelowHighMidpoint()
		{
			Assert.AreEqual(4, IBBMath.CeilToHalf(3.7));
		}
		
		[Test()]
		public void TestRoundHalfRoundsUpJustBelowHighMidpoint()
		{
			Assert.AreEqual(4, IBBMath.CeilToHalf(3.74));
		}
		
		[Test()]
		public void TestRoundHalfRoundsUpOnHighMidpoint()
		{
			Assert.AreEqual(4, IBBMath.CeilToHalf(3.75));
		}
		
		[Test()]
		public void TestRoundHalfRoundsUpJustAboveHighMidpoint()
		{
			Assert.AreEqual(4, IBBMath.CeilToHalf(3.76));
		}
		
		[Test()]
		public void TestRoundHalfRoundsUpAboveHighMidpoint()
		{
			Assert.AreEqual(4, IBBMath.CeilToHalf(3.8));
		}
		
		[Test()]
		public void TestRoundHalfUpDoesntAlterHalf()
		{
			Assert.AreEqual(3.5, IBBMath.CeilToHalf(3.5));
		}
		
		[Test()]
		public void TestRoundHalfUpDoesntRoundEvenNumber()
		{
			Assert.AreEqual(4, IBBMath.CeilToHalf(4));
		}
		
		[Test()]
		public void TestRoundHalfUpDoesntRoundOddNumber()
		{
			Assert.AreEqual(3, IBBMath.CeilToHalf(3));
		}
		
		[Test()]
		public void TestRoundHalfRoundsDownBelowLowMidpoint()
		{
			Assert.AreEqual(3, IBBMath.FloorToHalf(3.2));
		}
		
		[Test()]
		public void TestRoundHalfRoundsDownJustBelowLowMidpoint()
		{
			Assert.AreEqual(3, IBBMath.FloorToHalf(3.24));
		}
		
		[Test()]
		public void TestRoundHalfRoundsDownOnLowMidpoint()
		{
			Assert.AreEqual(3, IBBMath.FloorToHalf(3.25));
		}

		[Test()]
		public void TestRoundHalfRoundsDownJustAboveLowMidpoint()
		{
			Assert.AreEqual(3, IBBMath.FloorToHalf(3.26));
		}
		
		[Test()]
		public void TestRoundHalfRoundsDownAboveLowMidpoint()
		{
			Assert.AreEqual(3, IBBMath.FloorToHalf(3.3));
		}
		
		[Test()]
		public void TestRoundHalfRoundsDownBelowHighMidpoint()
		{
			Assert.AreEqual(3.5, IBBMath.FloorToHalf(3.7));
		}
		
		[Test()]
		public void TestRoundHalfRoundsDownJustBelowHighMidpoint()
		{
			Assert.AreEqual(3.5, IBBMath.FloorToHalf(3.74));
		}
		
		[Test()]
		public void TestRoundHalfRoundsDownOnHighMidpoint()
		{
			Assert.AreEqual(3.5, IBBMath.FloorToHalf(3.75));
		}
		
		[Test()]
		public void TestRoundHalfRoundsDownJustAboveHighMidpoint()
		{
			Assert.AreEqual(3.5, IBBMath.FloorToHalf(3.76));
		}
		
		[Test()]
		public void TestRoundHalfRoundsDownAboveHighMidpoint()
		{
			Assert.AreEqual(3.5, IBBMath.FloorToHalf(3.8));
		}
		
		[Test()]
		public void TestRoundHalfDownDoesntAlterHalf()
		{
			Assert.AreEqual(3.5, IBBMath.FloorToHalf(3.5));
		}
		
		[Test()]
		public void TestRoundHalfDownDoesntRoundEvenNumber()
		{
			Assert.AreEqual(4, IBBMath.FloorToHalf(4));
		}
		
		[Test()]
		public void TestRoundHalfDownDoesntRoundOddNumber()
		{
			Assert.AreEqual(3, IBBMath.FloorToHalf(3));
		}


		
	}
}