Exemple #1
0
            private static IEnumerable <ITestCaseData> GetTestCases()
            {
                const string testCasesDir = @"Pcre\TestCases";

                for (var fileIndex = 0; fileIndex < InputFiles.GetLength(0); ++fileIndex)
                {
                    var testFileName = InputFiles[fileIndex, 0];

                    using (var inputFs = File.OpenRead(Path.Combine(testCasesDir, testFileName)))
                        using (var outputFs = File.OpenRead(Path.Combine(testCasesDir, InputFiles[fileIndex, 1])))
                            using (var inputReader = new TestInputReader(inputFs))
                                using (var outputReader = new TestOutputReader(outputFs))
                                {
                                    var tests = inputReader.ReadTestCases().Zip(outputReader.ReadTestOutputs(), (i, o) => new
                                    {
                                        testCase       = i,
                                        expectedResult = o
                                    });

                                    foreach (var test in tests)
                                    {
                                        var testCase = new TestCaseData(test.testCase, test.expectedResult)
                                                       .SetCategory(testFileName)
                                                       .SetName(String.Format("{0} line {1:0000}", testFileName, test.testCase.Pattern.LineNumber))
                                                       .SetDescription(test.testCase.Pattern.Pattern);

                                        yield return(testCase);
                                    }
                                }
                }
            }
Exemple #2
0
            private static IEnumerable <ITestCaseData> GetTestCases()
            {
                var testCasesDir = Path.Combine(Path.GetDirectoryName(typeof(PcreTests).Assembly.Location) ?? throw new InvalidOperationException(), @"Pcre\TestCases");

                for (var fileIndex = 0; fileIndex < InputFiles.GetLength(0); ++fileIndex)
                {
                    var testFileName = InputFiles[fileIndex, 0];

                    using (var inputFs = File.OpenRead(Path.Combine(testCasesDir, testFileName)))
                        using (var outputFs = File.OpenRead(Path.Combine(testCasesDir, InputFiles[fileIndex, 1])))
                            using (var inputReader = new TestInputReader(inputFs))
                                using (var outputReader = new TestOutputReader(outputFs))
                                {
                                    var tests = inputReader.ReadTestCases().Zip(outputReader.ReadTestOutputs(), (i, o) => new
                                    {
                                        testCase       = i,
                                        expectedResult = o
                                    });

                                    foreach (var test in tests)
                                    {
                                        var testCase = new TestCaseData(test.testCase, test.expectedResult)
                                                       .SetCategory(testFileName)
                                                       .SetName($"{testFileName} line {test.testCase.Pattern.LineNumber:0000}")
                                                       .SetDescription(test.testCase.Pattern.Pattern);

                                        yield return(testCase);
                                    }
                                }
                }
            }
Exemple #3
0
            private static IEnumerable <ITestCaseData> GetTestCases()
            {
                var testCasesDir = Path.Combine(Path.GetDirectoryName(typeof(PcreTests).Assembly.Location) ?? throw new InvalidOperationException(), @"Pcre", "TestCases");

                for (var fileIndex = 0; fileIndex < InputFiles.GetLength(0); ++fileIndex)
                {
                    var testFileName = InputFiles[fileIndex, 0];
                    var testFilePath = Path.Combine(testCasesDir, testFileName);

                    using (var inputFs = File.OpenRead(testFilePath))
                        using (var outputFs = File.OpenRead(Path.Combine(testCasesDir, InputFiles[fileIndex, 1])))
                            using (var inputReader = new TestInputReader(inputFs))
                                using (var outputReader = new TestOutputReader(outputFs))
                                {
                                    var tests = inputReader.ReadTestInputs().Zip(outputReader.ReadTestOutputs(), (i, o) => new
                                    {
                                        input          = i,
                                        expectedResult = o
                                    });

                                    var testCases =
                                        from test in tests
                                        from jit in new[] { false, true }
                                    from span in new[] { false, true }
                                    let  testCase = new TestCase
                                    {
                                        TestFile       = testFilePath,
                                        Input          = test.input,
                                        ExpectedResult = test.expectedResult,
                                        Jit            = jit,
                                        Span           = span
                                    }
                                    select new TestCaseData(testCase)
                                    .SetCategory(testFileName)
                                    .SetName($"PCRE {testFileName}, Line {testCase.Input.Pattern.LineNumber:0000}, {(jit ? "JIT" : "Interpreted")}, {(span ? "Span" : "String")}")
                                    .SetDescription(testCase.Input.Pattern.Pattern);

                                    foreach (var testCase in testCases)
                                    {
                                        yield return(testCase);
                                    }
                                }
                }
            }