public void ContinuedFractionApproximatorConstructorTest()
        {
            ContinuedFractionApproximator app = new ContinuedFractionApproximator(100);

            app.IterationLimit.ShouldBe(100);

            Should.Throw <ArgumentOutOfRangeException>(() => app = new ContinuedFractionApproximator(0));
            Should.Throw <ArgumentOutOfRangeException>(() => app = new ContinuedFractionApproximator(-1));
        }
        public void ContinuedFractionApproximatorGetNearestRationalTest()
        {
            ContinuedFractionApproximator app = new ContinuedFractionApproximator(100);
            Rational nearest = app.GetNearestRational(1 / 4.0, 0.00000001);

            ((Double)nearest).ShouldBe(1 / 4.0, 0.00000001);

            nearest = app.GetNearestRational(5 / 4.0, 0.00000001);
            ((Double)nearest).ShouldBe(5 / 4.0, 0.00000001);

            nearest = app.GetNearestRational(0, 0.00000001);
            ((Double)nearest).ShouldBe(0, 0.00000001);

            nearest = app.GetNearestRational(1.0, 0.00000001);
            ((Double)nearest).ShouldBe(1.0, 0.00000001);

            nearest = app.GetNearestRational(1 / 3.0, 0.00000001);
            ((Double)nearest).ShouldBe(1 / 3.0, 0.00000001);

            nearest = app.GetNearestRational(4 / 3.0, 0.000000000001);
            ((Double)nearest).ShouldBe(4 / 3.0, 0.00000001);

            nearest = app.GetNearestRational(-4 / 3.0, 0.00000001);
            ((Double)nearest).ShouldBe(-4 / 3.0, 0.00000001);

            nearest = app.GetNearestRational(11 / 7.0, 0.00000001);
            ((Double)nearest).ShouldBe(11 / 7.0, 0.00000001);

            nearest = app.GetNearestRational(-971 / 1579.0, 0.00000001);
            ((Double)nearest).ShouldBe(-971 / 1579.0, 0.00000001);

            nearest = app.GetNearestRational(3 / 12289.0, 0.00000001);
            ((Double)nearest).ShouldBe(3 / 12289.0, 0.00000001);

            nearest = app.GetNearestRational(-30223 / 3.0, 0.00000001);
            ((Double)nearest).ShouldBe(-30223 / 3.0, 0.00000001);

            nearest = app.GetNearestRational(4503599627370496, 0.00000001);
            ((Double)nearest).ShouldBe(4503599627370496, 0.00000001);

            nearest = app.GetNearestRational(-4503599627370496, 0.00000001);
            ((Double)nearest).ShouldBe(-4503599627370496, 0.00000001);

            Should.Throw <ArgumentOutOfRangeException>(() => app.GetNearestRational(4503599627370497, 0.00000001));
            Should.Throw <ArgumentOutOfRangeException>(() => app.GetNearestRational(-4503599627370497, 0.00000001));
            Should.Throw <ArgumentOutOfRangeException>(() => app.GetNearestRational(1.0, 0));
        }