Rev | Line | |
---|
[11180] | 1 | using System;
|
---|
| 2 | using Mehroz;
|
---|
| 3 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
| 4 |
|
---|
| 5 | namespace AlgorithmBehaviorUnitTests {
|
---|
| 6 | [TestClass]
|
---|
| 7 | public class FractionTest {
|
---|
| 8 |
|
---|
| 9 | [TestMethod]
|
---|
| 10 | public void TestPrecision() {
|
---|
| 11 | double testDouble1 = 1234.56789;
|
---|
| 12 | float testFloat1 = 1234.56789F;
|
---|
| 13 | Fraction testFraction1 = new Fraction(testDouble1);
|
---|
| 14 |
|
---|
| 15 | Assert.AreEqual(testDouble1, testFraction1.ToDouble(5));
|
---|
| 16 |
|
---|
| 17 | for (int i = 0; i < 100; i++) {
|
---|
| 18 | testDouble1 *= 10;
|
---|
| 19 | testFraction1 *= 10;
|
---|
| 20 | testFloat1 *= 10;
|
---|
| 21 |
|
---|
| 22 | Console.WriteLine("testDouble1 in " + i + " iteration: \t\t\t\t" + String.Format("{0:F5}", testDouble1));
|
---|
| 23 | Console.WriteLine("testFloat1 in " + i + " iteration: \t\t\t\t" + String.Format("{0:F5}", testFloat1));
|
---|
| 24 | Console.WriteLine("testFraction1 (ToDouble(5)) in " + i + " iteration: \t" + String.Format("{0:F5}", testFraction1.ToDouble(5)));
|
---|
| 25 | Console.WriteLine("testFraction1 (ToString()) in " + i + " iteration: \t\t" + testFraction1.ToString());
|
---|
| 26 | Console.WriteLine();
|
---|
| 27 | }
|
---|
| 28 | }
|
---|
| 29 | }
|
---|
| 30 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.