Exemplo n.º 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));
            }
        }
Exemplo n.º 2
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));
            }
        }