示例#1
0
        public void GcMathRandomMinMax()
        {
            var seed = (uint)(1 + UnityEngine.Random.value * (uint.MaxValue - 1));

            GcMath.SetRandomSeed(seed);

            for (var i = 0; i < 100; i++)
            {
                var a   = UnityEngine.Random.Range(int.MinValue, int.MaxValue);
                var b   = UnityEngine.Random.Range(int.MinValue, int.MaxValue);
                var min = UnityEngine.Mathf.Min(a, b);
                var max = UnityEngine.Mathf.Max(a, b);

                var v = GcMath.Random(min, max);
                Assert.IsTrue(v >= min && v < max);
            }
            for (var i = 0; i < 100; i++)
            {
                var a   = UnityEngine.Random.Range(float.MinValue, float.MaxValue);
                var b   = UnityEngine.Random.Range(float.MinValue, float.MaxValue);
                var min = UnityEngine.Mathf.Min(a, b);
                var max = UnityEngine.Mathf.Max(a, b);

                var v = GcMath.Random(min, max);
                Assert.IsTrue(v >= min && v < max);
            }
        }
示例#2
0
        public void GcMathRandom()
        {
            var seed = (uint)(1 + UnityEngine.Random.value * (uint.MaxValue - 1));

            GcMath.SetRandomSeed(seed);

            for (var i = 0; i < 100; i++)
            {
                var v = GcMath.Random();
                Assert.IsTrue(v > 0f && v < 1f);
            }
        }