예제 #1
0
        protected void Test([CallerMemberName] string testName = null)
        {
            var(success, diagnostics) = RuntimeCompiler.CompileToExe(testName, TestSource);
            Assert.IsTrue(success, message: string.Join(Environment.NewLine, diagnostics));

            for (int i = 0; i < TestInputs.Count; ++i)
            {
                var(exitCode, output) = RuntimeCompiler.ExecuteExe(testName, TestInputs[i]);
                Assert.AreEqual(0, exitCode, message: "Non-zero exit code (runtime error).");
                Assert.AreEqual(TestOutputs[i], output);
            }
        }
예제 #2
0
        public IOTestSuite()
        {
            var(success, diagnostics) = RuntimeCompiler.CompileToExe(_fastInputExeName, _fastInputSource);
            if (!success)
            {
                throw new Exception();
            }
            (success, diagnostics) = RuntimeCompiler.CompileToExe(_fastInputAndOutputExeName, _fastInputAndOutputSource);
            if (!success)
            {
                throw new Exception();
            }

            (success, diagnostics) = RuntimeCompiler.CompileToExe(_slowInputExeName, _slowInputSource);
            if (!success)
            {
                throw new Exception();
            }
            (success, diagnostics) = RuntimeCompiler.CompileToExe(_slowInputAndOutputExeName, _slowInputAndOutputSource);
            if (!success)
            {
                throw new Exception();
            }

            (success, diagnostics) = RuntimeCompiler.CompileToExe(_slowestInputExeName, _slowestInputSource);
            if (!success)
            {
                throw new Exception();
            }
            (success, diagnostics) = RuntimeCompiler.CompileToExe(_slowestInputAndOutputExeName, _slowestInputAndOutputSource);
            if (!success)
            {
                throw new Exception();
            }

            var inputBuilder = new StringBuilder();

            inputBuilder.AppendLine($"{_inputSize}");
            for (int i = 0; i < _inputSize; ++i)
            {
                inputBuilder.Append(InputGenerator.GenerateRandomInt(0, 100000));
                inputBuilder.AppendLine();
            }
            _input = inputBuilder.ToString();
        }