Exemple #1
0
 public void FloatTest()
 {
     /*Assert.That(4.0f, Is.EqualTo(4.0f).Within(4.0f * epsilon),
      *      "Floats constraint-based");*/
     //Assert.AreEqual(4.0f, 4.0f, 4.0f * epsilon, "Floats");
     Assert.True(Util.InEpsilon(4.0f, 4.0f, epsilon * 4.0f), "Floats");
 }
Exemple #2
0
        public void AssocAddCheck()
        {
            Func <int, int, int, bool> func = (x, y, z) => {
                double a = (double)x; double b = (double)y; double c = (double)z;
                return(Util.InEpsilon((a + b) + c, a + (b + c),
                                      epsilon * ((a + b) + c)));
            };

            Prop.ForAll <int, int, int>(func).QuickCheckThrowOnFailure();
        }
Exemple #3
0
        public bool SquareProp(uint x)
        {
            var funcs = new Func <float, float>[] { Classic.SquareLp,
                                                    Classic.SquareI };
            float n   = (float)(x % 100 + 1);
            var   ans = Math.Pow(n, 2.0f);

            return(funcs.Aggregate(true, (acc, f) => acc && Util.InEpsilon(ans,
                                                                           f(n), epsilon * ans)));
        }
Exemple #4
0
        public void MinSortHeadCheckB()
        {
            Func <IEnumerable <double>, bool> func = xs => {
                double[] ys = xs.Select(e => e).ToArray();
                Array.Sort(ys);
                return(Util.InEpsilon(xs.Min(), ys[0], epsilon * xs.Min()));
            };

            Arb.Register <MyArbitraries>();
            Prop.ForAll <IEnumerable <double> >(func).QuickCheckThrowOnFailure();
        }
Exemple #5
0
        public void MinSortHeadCheckA()
        {
            Func <FsCheck.NonEmptyArray <FsCheck.NormalFloat>, bool> func = xs => {
                double[] ys = xs.Get.Select(e => e.Get).ToArray();
                Array.Sort(ys);
                return(Util.InEpsilon(xs.Get.Min().Get, ys[0], epsilon * ys[0]));
            };

            Prop.ForAll <FsCheck.NonEmptyArray <FsCheck.NormalFloat> >(
                func).QuickCheckThrowOnFailure();
        }
Exemple #6
0
        public bool ExptProp(uint x, uint y)
        {
            var funcs = new Func <float, float, float>[] { Classic.ExptLp,
                                                           Classic.ExptI };
            float b = (float)(x % 19 + 1); float n = (float)(y % 10 + 1);
            var   ans = Math.Pow(b, n);

            /*bool res = true;
             * foreach (var f in funcs)
             *      res = res && Util.InEpsilon(ans, f(b, n), epsilon * ans);
             * return res;*/
            return(funcs.Aggregate(true, (acc, f) => acc && Util.InEpsilon(ans,
                                                                           f(b, n), epsilon * ans)));
        }
Exemple #7
0
 public bool MinSortHeadPropB(IEnumerable <double> xs)
 {
     double[] ys = xs.Select(e => e).ToArray();
     Array.Sort(ys);
     return(Util.InEpsilon(xs.Min(), ys[0], epsilon * xs.Min()));
 }
Exemple #8
0
 public bool MinSortHeadPropA(FsCheck.NonEmptyArray <FsCheck.NormalFloat> xs)
 {
     double[] ys = xs.Get.Select(e => e.Get).ToArray();
     Array.Sort(ys);
     return(Util.InEpsilon(xs.Get.Min().Get, ys[0], epsilon * ys[0]));
 }
Exemple #9
0
        public bool AssocAddProp(int x, int y, int z)
        {
            double a = (double)x; double b = (double)y; double c = (double)z;

            return(Util.InEpsilon((a + b) + c, a + (b + c), epsilon * ((a + b) + c)));
        }