private static void CheckSimpleFloats()
        {
            List <float> list = Autotests_RandomNumbers.RandomFloats(500).ToList <float>();

            if (list.Any((float x) => x < 0f || x > 1f))
            {
                Log.Error("Float out of range.", false);
            }
            if (list.Any((float x) => x < 0.1f))
            {
                if (list.Any((float x) => (double)x > 0.5 && (double)x < 0.6))
                {
                    if (list.Any((float x) => (double)x > 0.9))
                    {
                        goto IL_C7;
                    }
                }
            }
            Log.Warning("Possibly uneven distribution.", false);
IL_C7:
            list = Autotests_RandomNumbers.RandomFloats(1300000).ToList <float>();
            int num = list.Count((float x) => (double)x < 0.1);

            Log.Message("< 0.1 count (should be ~10%): " + (float)num / (float)list.Count <float>() * 100f + "%", false);
            num = list.Count((float x) => (double)x < 0.0001);
            Log.Message("< 0.0001 count (should be ~0.01%): " + (float)num / (float)list.Count <float>() * 100f + "%", false);
        }
 public static void Run()
 {
     Log.Message("Running random numbers tests.", false);
     Autotests_RandomNumbers.CheckSimpleFloats();
     Autotests_RandomNumbers.CheckIntsRange();
     Autotests_RandomNumbers.CheckIntsDistribution();
     Autotests_RandomNumbers.CheckSeed();
     Log.Message("Finished.", false);
 }
Пример #3
0
        private static void CheckSimpleFloats()
        {
            List <float> list = Autotests_RandomNumbers.RandomFloats(500).ToList();

            if (list.Any((float x) => x < 0.0 || x > 1.0))
            {
                Log.Error("Float out of range.");
            }
            if (!list.Any((float x) => x < 0.10000000149011612) || !list.Any((float x) => (double)x > 0.5 && (double)x < 0.6) || !list.Any((float x) => (double)x > 0.9))
            {
                Log.Warning("Possibly uneven distribution.");
            }
            list = Autotests_RandomNumbers.RandomFloats(1300000).ToList();
            int num = list.Count((float x) => (double)x < 0.1);

            Log.Message("< 0.1 count (should be ~10%): " + (float)((float)num / (float)list.Count() * 100.0) + "%");
            num = list.Count((float x) => (double)x < 0.0001);
            Log.Message("< 0.0001 count (should be ~0.01%): " + (float)((float)num / (float)list.Count() * 100.0) + "%");
        }
Пример #4
0
        private static void CheckSeed()
        {
            int seed = Rand.Seed = 10;
            int @int = Rand.Int;
            int int2 = Rand.Int;

            Rand.Seed = seed;
            int int3 = Rand.Int;
            int int4 = Rand.Int;

            if (@int != int3 || int2 != int4)
            {
                Log.Error("Same seed, different values.");
            }
            Autotests_RandomNumbers.TestPushSeed(15, 20);
            Autotests_RandomNumbers.TestPushSeed(-2147483645, 20);
            Autotests_RandomNumbers.TestPushSeed(6, 2147483647);
            Autotests_RandomNumbers.TestPushSeed(-2147483645, 2147483642);
            Autotests_RandomNumbers.TestPushSeed(-1947483645, 1147483642);
            Autotests_RandomNumbers.TestPushSeed(455, 648023);
        }