protected override void RunTestFrame()
        {
            foreach (var c in m_Cases)
            {
                m_Timer.Restart();
                MathUtility.Approximately(c.x, c.y);
                m_Timer.Stop();
                m_ElapsedTicks += m_Timer.ElapsedTicks;

                m_TimerB.Restart();
                Mathf.Approximately(c.x, c.y);
                m_TimerB.Stop();
                m_ElapsedTicksB += m_TimerB.ElapsedTicks;
            }
        }
예제 #2
0
        public void ApproximatelyGivesSameResultsAsMathf(float r)
        {
            const int callCount = 100;
            var       testCases = new Vector2[callCount];

            Random.InitState(0);
            for (int i = 0; i < callCount; i++)
            {
                testCases[i] = new Vector2(Random.Range(-r, r), Random.Range(-r, r));
            }

            foreach (var pair in testCases)
            {
                var ourResult   = MathUtility.Approximately(pair.x, pair.y);
                var mathfResult = Mathf.Approximately(pair.x, pair.y);
                Assert.AreEqual(mathfResult, ourResult, string.Format(
                                    "comparing {0} to {1} - Mathf said {2} , we said {3}", pair.x, pair.y, mathfResult, ourResult));
            }
        }