예제 #1
0
        public void IntSequence()
        {
            Fix64Random rand = new Fix64Random(1234);

            for (int i = 0; i < 100; i++)
            {
                Fix64 value = rand.NextInt(1337);

                Fix64 expected = Fix64RandomExpectedValues.ExpectedInts[i];
                Assert.True(value == expected, string.Format("NextInt() sequence {0} = expected {1} but got {2}", i, expected, value));
            }
        }
예제 #2
0
        private void TestIntRange(int maxValue, int seed)
        {
            bool[]      valueReceived = new bool[maxValue];
            Fix64Random rand          = new Fix64Random(seed);

            for (int i = 0; i < maxValue * 100; i++)
            {
                Fix64 value = rand.NextInt(maxValue);
                Assert.True(value >= Fix64.Zero && value < maxValue, string.Format("NextInt({0}) = expected 0 <= result < {0} but got {1}", maxValue, value));
                valueReceived[(int)value] = true;
            }

            for (int i = 0; i < maxValue; i++)
            {
                Assert.True(valueReceived[i], string.Format("NextInt({0}) = expected to receive {1} but never got it", maxValue, i));
            }
        }