public void TestPrg()
        {
            // 2 tests for integer interval and 2 tests for unit interval.
            var prgTests = new ITestConfiguration[4];

            for (uint i = 0; i < prgTests.Length; i++)
            {
                prgTests[i] = new PrgTestConfiguration
                {
                    Seed            = i,
                    Iterations      = 1000,
                    UniformInterval = i < 2 ? new Tuple <uint, uint>(i * 10, (i + 10) * 10) : null,
                };
            }
            Run(outputFilePatternExpected, outputFilePatternActual, outputJsonConfigFile, prgTests);

            for (uint i = 0; i < 2; i++)
            {
                // integer content so should be exact match
                CompareExactMatch(FormatPath(outputFilePatternExpected, i), FormatPath(outputFilePatternActual, i));
            }

            for (uint i = 2; i < 4; i++)
            {
                float[] expected = File.ReadAllLines(FormatPath(outputFilePatternExpected, i)).Select(l => Convert.ToSingle(l)).ToArray();
                float[] actual   = File.ReadAllLines(FormatPath(outputFilePatternActual, i)).Select(l => Convert.ToSingle(l)).ToArray();

                Assert.AreEqual(expected.Length, actual.Length);
                for (int j = 0; j < expected.Length; j++)
                {
                    // allow slightly different float precision
                    Assert.IsTrue(Math.Abs(expected[j] - actual[j]) < PrecisionOffset);
                }
            }
        }
Example #2
0
        public void TestPrg()
        {
            // 2 tests for integer interval and 2 tests for unit interval.
            var prgTests = new ITestConfiguration[4];
            for (uint i = 0; i < prgTests.Length; i++)
            {
                prgTests[i] = new PrgTestConfiguration
                {
                    Seed = i,
                    Iterations = 1000,
                    UniformInterval = i < 2 ? new Tuple<uint, uint>(i * 10, (i + 10) * 10) : null,
                };
            }
            Run(outputFilePatternExpected, outputFilePatternActual, outputJsonConfigFile, prgTests);

            for (uint i = 0; i < 2; i++)
            {
                // integer content so should be exact match
                CompareExactMatch(FormatPath(outputFilePatternExpected, i), FormatPath(outputFilePatternActual, i));
            }

            for (uint i = 2; i < 4; i++)
            {
                float[] expected = File.ReadAllLines(FormatPath(outputFilePatternExpected, i)).Select(l => Convert.ToSingle(l)).ToArray();
                float[] actual = File.ReadAllLines(FormatPath(outputFilePatternActual, i)).Select(l => Convert.ToSingle(l)).ToArray();

                Assert.AreEqual(expected.Length, actual.Length);
                for (int j = 0; j < expected.Length; j++)
                {
                    // allow slightly different float precision
                    Assert.IsTrue(Math.Abs(expected[j] - actual[j]) < PrecisionOffset);
                }
            }
        }