changeset 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
files IBBoard.Tests.csproj Lang/IBBMathTests.cs
diffstat 2 files changed, 138 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IBBoard.Tests.csproj	Sun May 17 16:09:38 2009 +0000
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.50727</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{4160F7B6-4CFA-41FC-B5D7-5C9AE06FEBA7}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AssemblyName>IBBoard.Tests2</AssemblyName>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="Lang\IBBMathTests.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="nunit.core, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
+    <Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <ItemGroup>
+    <Folder Include="Lang\" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\IBBoard\IBBoard.csproj">
+      <Project>{5DFD64F6-FC2B-4B4F-B92E-483BAC468105}</Project>
+      <Name>IBBoard</Name>
+    </ProjectReference>
+  </ItemGroup>
+</Project>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Lang/IBBMathTests.cs	Sun May 17 16:09:38 2009 +0000
@@ -0,0 +1,92 @@
+//  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));
+		}
+	}
+}