Exemple #1
0
        private static Settings GetSettings()
        {
            var settings = new Settings
                               {
                                   Compilers = new List<Compiler>(),
                                   TestingDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()),
                               };

            settings.Compilers.Add(Compiler.VC8Compiler);
            settings.Compilers.Add(Compiler.VC6Compiler);
            settings.Compilers.Add(Compiler.Delphi7Compiler);
            settings.Compilers.Add(Compiler.Java6Compiler);
            settings.Compilers.Add(Compiler.DotNet2Compiler);
            settings.Compilers.Add(Compiler.DotNet3Compiler);

            return settings;
        }
        public string Compile(string source, string language, string[] input, string[] output, int timelimit, int memorylimit)
        {
            for (int i = 0; i < input.Length; i++)
            {
                Program p = new Program();
                p.Source = source;
                p.MemoryLimit = memorylimit;
                p.TimeLimit = timelimit;
                p.InputTest = input[i];
                p.OutputTest = output[i];

                switch (language)
                {
                    case "CPP": p.Language = Language.VC8; break;
                    case "CS": p.Language = Language.CSharp3; break;
                    case "Delphi": p.Language = Language.Delphi7; break;
                    case "Java": p.Language = Language.Java6; break;
                }

                var settings = new Settings();
                settings.Compilers = new List<Compiler>();
                settings.TestingDirectory = System.IO.Path.Combine(System.IO.Path.GetTempPath(), Guid.NewGuid().ToString());
                settings.Compilers.Add(Compiler.VC8Compiler);
                settings.Compilers.Add(Compiler.DotNet3Compiler);
                settings.Compilers.Add(Compiler.Delphi7Compiler);
                settings.Compilers.Add(Compiler.Java6Compiler);

                CompilationTester tester = new CompilationTester(settings);

                Result result = tester.TestProgram(p);

                if (result.ProgramStatus != Status.Accepted)
                {
                    return System.Enum.GetName(typeof(Status), result.ProgramStatus) + " Test: " + i.ToString();
                }
            }

            return "Accepted";
        }
Exemple #3
0
 /// <summary>
 /// Creates new instance of <see cref="Tester"/> class.
 /// </summary>
 /// 
 /// <param name="settings">
 /// Settings of this component.
 /// </param>
 public CompilationTester(Settings settings)
 {
     ProjectHelper.ValidateNotNull(settings, "settings");
     this.Settings = settings;
 }