コード例 #1
0
        public void DecimalSequence()
        {
            Fix64Random rand = new Fix64Random(1234);

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

                Fix64 expected = Fix64RandomExpectedValues.ExpectedDecimals[i];
                Assert.True(value == expected, string.Format("Next() 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));
            }
        }
コード例 #3
0
        public void DecimalRange()
        {
            Fix64Random rand = new Fix64Random(123413587);

            const int buckets = 1000;

            bool[] valueReceived = new bool[buckets];

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

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