Mercurial > repos > IBBoard.Tests
annotate CustomMath/IBBMathTests.cs @ 49:99e4c1949c92 default tip
* Update to v2.6 of NUnit and new syntax/API changes
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 28 Apr 2013 19:32:14 +0100 |
parents | 37642712f632 |
children |
rev | line source |
---|---|
0
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // This file (IBBMathTest.cs) is a part of the IBBoard.Tests project and is copyright 2009 IBBoard |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 // 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. |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 // |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 using System; |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 using NUnit.Framework; |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 |
3
8c45831988c3
* Fix namespace of IBBMathTests so that they test new class
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
9 namespace IBBoard.CustomMath |
0
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 { |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 [TestFixture()] |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 public class IBBMathTest |
1
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
13 { |
0
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 [Test()] |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 public void TestRoundHalfPerformsBankersRoundingBelowLowMidpoint() |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 { |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 Assert.AreEqual(3, IBBMath.RoundToHalf(3.2)); |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 } |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 [Test()] |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 public void TestRoundHalfPerformsBankersRoundingJustBelowLowMidpoint() |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 { |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 Assert.AreEqual(3, IBBMath.RoundToHalf(3.24)); |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 } |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 [Test()] |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 public void TestRoundHalfPerformsBankersRoundingOnLowMidpoint() |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 { |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 Assert.AreEqual(3, IBBMath.RoundToHalf(3.25)); |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 } |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 [Test()] |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 public void TestRoundHalfPerformsBankersRoundingJustAboveLowMidpoint() |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 { |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 Assert.AreEqual(3.5, IBBMath.RoundToHalf(3.26)); |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 } |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 [Test()] |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 public void TestRoundHalfPerformsBankersRoundingAboveLowMidpoint() |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 { |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 Assert.AreEqual(3.5, IBBMath.RoundToHalf(3.3)); |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 } |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 [Test()] |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
45 public void TestRoundHalfPerformsBankersRoundingBelowHighMidpoint() |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 { |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 Assert.AreEqual(3.5, IBBMath.RoundToHalf(3.7)); |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
48 } |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
49 |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
50 [Test()] |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 public void TestRoundHalfPerformsBankersRoundingJustBelowHighMidpoint() |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
52 { |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
53 Assert.AreEqual(3.5, IBBMath.RoundToHalf(3.74)); |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
54 } |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
55 |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
56 [Test()] |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 public void TestRoundHalfPerformsBankersRoundingOnHighMidpoint() |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
58 { |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
59 Assert.AreEqual(4, IBBMath.RoundToHalf(3.75)); |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
60 } |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
61 |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
62 [Test()] |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
63 public void TestRoundHalfPerformsBankersRoundingJustAboveHighMidpoint() |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
64 { |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
65 Assert.AreEqual(4, IBBMath.RoundToHalf(3.76)); |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
66 } |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
67 |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
68 [Test()] |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
69 public void TestRoundHalfPerformsBankersRoundingAboveHighMidpoint() |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
70 { |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
71 Assert.AreEqual(4, IBBMath.RoundToHalf(3.8)); |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
72 } |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
73 |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
74 [Test()] |
1
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
75 public void TestRoundHalfDoesntAlterHalf() |
0
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
76 { |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
77 Assert.AreEqual(3.5, IBBMath.RoundToHalf(3.5)); |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
78 } |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
79 |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
80 [Test()] |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
81 public void TestRoundHalfDoesntRoundEvenNumber() |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
82 { |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
83 Assert.AreEqual(4, IBBMath.RoundToHalf(4)); |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
84 } |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
85 |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
86 [Test()] |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
87 public void TestRoundHalfDoesntRoundOddNumber() |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
88 { |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
89 Assert.AreEqual(3, IBBMath.RoundToHalf(3)); |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
90 } |
1
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
91 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
92 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
93 public void TestRoundHalfRoundsUpBelowLowMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
94 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
95 Assert.AreEqual(3.5, IBBMath.CeilToHalf(3.2)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
96 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
97 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
98 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
99 public void TestRoundHalfRoundsUpJustBelowLowMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
100 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
101 Assert.AreEqual(3.5, IBBMath.CeilToHalf(3.24)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
102 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
103 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
104 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
105 public void TestRoundHalfRoundsUpOnLowMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
106 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
107 Assert.AreEqual(3.5, IBBMath.CeilToHalf(3.25)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
108 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
109 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
110 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
111 public void TestRoundHalfRoundsUpJustAboveLowMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
112 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
113 Assert.AreEqual(3.5, IBBMath.CeilToHalf(3.26)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
114 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
115 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
116 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
117 public void TestRoundHalfRoundsUpAboveLowMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
118 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
119 Assert.AreEqual(3.5, IBBMath.CeilToHalf(3.3)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
120 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
121 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
122 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
123 public void TestRoundHalfRoundsUpBelowHighMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
124 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
125 Assert.AreEqual(4, IBBMath.CeilToHalf(3.7)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
126 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
127 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
128 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
129 public void TestRoundHalfRoundsUpJustBelowHighMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
130 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
131 Assert.AreEqual(4, IBBMath.CeilToHalf(3.74)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
132 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
133 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
134 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
135 public void TestRoundHalfRoundsUpOnHighMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
136 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
137 Assert.AreEqual(4, IBBMath.CeilToHalf(3.75)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
138 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
139 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
140 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
141 public void TestRoundHalfRoundsUpJustAboveHighMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
142 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
143 Assert.AreEqual(4, IBBMath.CeilToHalf(3.76)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
144 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
145 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
146 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
147 public void TestRoundHalfRoundsUpAboveHighMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
148 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
149 Assert.AreEqual(4, IBBMath.CeilToHalf(3.8)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
150 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
151 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
152 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
153 public void TestRoundHalfUpDoesntAlterHalf() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
154 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
155 Assert.AreEqual(3.5, IBBMath.CeilToHalf(3.5)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
156 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
157 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
158 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
159 public void TestRoundHalfUpDoesntRoundEvenNumber() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
160 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
161 Assert.AreEqual(4, IBBMath.CeilToHalf(4)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
162 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
163 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
164 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
165 public void TestRoundHalfUpDoesntRoundOddNumber() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
166 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
167 Assert.AreEqual(3, IBBMath.CeilToHalf(3)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
168 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
169 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
170 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
171 public void TestRoundHalfRoundsDownBelowLowMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
172 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
173 Assert.AreEqual(3, IBBMath.FloorToHalf(3.2)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
174 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
175 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
176 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
177 public void TestRoundHalfRoundsDownJustBelowLowMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
178 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
179 Assert.AreEqual(3, IBBMath.FloorToHalf(3.24)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
180 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
181 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
182 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
183 public void TestRoundHalfRoundsDownOnLowMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
184 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
185 Assert.AreEqual(3, IBBMath.FloorToHalf(3.25)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
186 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
187 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
188 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
189 public void TestRoundHalfRoundsDownJustAboveLowMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
190 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
191 Assert.AreEqual(3, IBBMath.FloorToHalf(3.26)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
192 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
193 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
194 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
195 public void TestRoundHalfRoundsDownAboveLowMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
196 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
197 Assert.AreEqual(3, IBBMath.FloorToHalf(3.3)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
198 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
199 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
200 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
201 public void TestRoundHalfRoundsDownBelowHighMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
202 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
203 Assert.AreEqual(3.5, IBBMath.FloorToHalf(3.7)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
204 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
205 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
206 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
207 public void TestRoundHalfRoundsDownJustBelowHighMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
208 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
209 Assert.AreEqual(3.5, IBBMath.FloorToHalf(3.74)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
210 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
211 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
212 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
213 public void TestRoundHalfRoundsDownOnHighMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
214 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
215 Assert.AreEqual(3.5, IBBMath.FloorToHalf(3.75)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
216 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
217 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
218 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
219 public void TestRoundHalfRoundsDownJustAboveHighMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
220 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
221 Assert.AreEqual(3.5, IBBMath.FloorToHalf(3.76)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
222 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
223 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
224 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
225 public void TestRoundHalfRoundsDownAboveHighMidpoint() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
226 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
227 Assert.AreEqual(3.5, IBBMath.FloorToHalf(3.8)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
228 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
229 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
230 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
231 public void TestRoundHalfDownDoesntAlterHalf() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
232 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
233 Assert.AreEqual(3.5, IBBMath.FloorToHalf(3.5)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
234 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
235 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
236 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
237 public void TestRoundHalfDownDoesntRoundEvenNumber() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
238 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
239 Assert.AreEqual(4, IBBMath.FloorToHalf(4)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
240 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
241 |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
242 [Test()] |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
243 public void TestRoundHalfDownDoesntRoundOddNumber() |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
244 { |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
245 Assert.AreEqual(3, IBBMath.FloorToHalf(3)); |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
246 } |
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
247 |
11
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
248 [Test()] |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
249 public void TestPercentageCalculations() |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
250 { |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
251 Assert.AreEqual(50, IBBMath.Percentage(1,2)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
252 Assert.AreEqual(50, IBBMath.Percentage(2,4)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
253 Assert.AreEqual(25, IBBMath.Percentage(1,4)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
254 Assert.AreEqual(10, IBBMath.Percentage(1,10)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
255 Assert.AreEqual(1, IBBMath.Percentage(1,100)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
256 Assert.AreEqual(0.1, IBBMath.Percentage(1,1000)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
257 Assert.AreEqual(200, IBBMath.Percentage(2,1)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
258 Assert.AreEqual(-50, IBBMath.Percentage(-1,2)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
259 Assert.AreEqual(-50, IBBMath.Percentage(-2,4)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
260 Assert.AreEqual(-50, IBBMath.Percentage(1,-2)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
261 Assert.AreEqual(-50, IBBMath.Percentage(2,-4)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
262 } |
1
80c42a1101a8
Closes #19 - Add rounding to half methods
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
263 |
11
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
264 [Test()] |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
265 public void TestPercentageCalculationsForZero() |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
266 { |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
267 Assert.AreEqual(0, IBBMath.Percentage(0,2)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
268 Assert.AreEqual(0, IBBMath.Percentage(0,4)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
269 Assert.AreEqual(0, IBBMath.Percentage(0,10)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
270 Assert.AreEqual(0, IBBMath.Percentage(0,-2)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
271 Assert.AreEqual(0, IBBMath.Percentage(0,-4)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
272 Assert.AreEqual(0, IBBMath.Percentage(0,-10)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
273 } |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
274 |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
275 [Test()] |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
276 public void TestPercentageCalculationsWithZeroAsDivisor() |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
277 { |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
278 Assert.AreEqual(double.PositiveInfinity, IBBMath.Percentage(1,0)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
279 Assert.AreEqual(double.PositiveInfinity, IBBMath.Percentage(2,0)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
280 Assert.AreEqual(double.NegativeInfinity, IBBMath.Percentage(-1,0)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
281 Assert.AreEqual(double.NegativeInfinity, IBBMath.Percentage(-2,0)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
282 } |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
283 |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
284 [Test()] |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
285 public void TestPercentageCalculationsWithZeroAsNumberAndDivisor() |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
286 { |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
287 Assert.AreEqual(double.NaN, IBBMath.Percentage(0,0)); |
37642712f632
* Tests for method for making percentage of one integer compared to another to ensure consistency
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
288 } |
0
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
289 } |
7bd668aeba3c
Re #19 - Add round to half\n * Commit tests for rounding
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
290 } |