Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/FractionTest.cs @ 11294

Last change on this file since 11294 was 11180, checked in by ascheibe, 10 years ago

#1886 added unit test

File size: 1.1 KB
Line 
1using System;
2using Mehroz;
3using Microsoft.VisualStudio.TestTools.UnitTesting;
4
5namespace 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.