public void ConvertFromInt()
        {
            Rational r = 5;

            AssertEqual(5, 1, r);
        }
 public void AssertEqual(int expectedNumerator, int expectedDenominator, Rational actual)
 {
     Assert.False(actual.IsNan);
     Assert.AreEqual(expectedNumerator, actual.Numerator);
     Assert.AreEqual(expectedDenominator, actual.Denominator);
 }
        public void ConvertToDouble(int numerator, int denominator, double expectedValue)
        {
            double v = new Rational(numerator, denominator);

            Assert.AreEqual(expectedValue, v, 1e-7);
        }
예제 #4
0
 private static Rational MoveSignToNumerator(Rational rational)
 {
     return(new Rational(rational.Numerator * Math.Sign(rational.Denominator),
                         rational.Denominator * Math.Sign(rational.Denominator)));
 }
예제 #5
0
 private static int GetChangedNumerator(Rational rational, int commonDenominator)
 {
     return(rational.Numerator * (commonDenominator / rational.Denominator));
 }
예제 #6
0
 private static bool CheckArgumetIsNaN(Rational r1, Rational r2)
 {
     return(r1.IsNan || r2.IsNan);
 }
예제 #7
0
        public void ConvertToDouble()
        {
            double v = new Rational(1, 2);

            Assert.AreEqual(0.5, v, 1e-7);
        }
예제 #8
0
 public void Equal(int numerator, int denominator, Rational b)
 {
     Assert.False(b.IsNan);
     Assert.AreEqual(numerator, b.Numerator);
     Assert.AreEqual(denominator, b.Denominator);
 }