Esempio n. 1
0
    def test_tle_python(self):
        code = '''
import time
time.sleep(%s)
        '''

        do_problem_mock('tle test', 1, [''], [''])
        verdict = judge.get_verdict(1, 'py', (code % 1.5))
        self.assertEqual(verdict, Verdict.TLE)

        verdict = judge.get_verdict(1, 'py', (code % 0.5))
        self.assertNotEqual(verdict, Verdict.TLE)
Esempio n. 2
0
    def test_pe_python(self):
        do_problem_mock('pe test', 1, [''], ['ANSWER'])
        code = '''
print("Answer")
        '''
        verdict = judge.get_verdict(1, 'py', code)
        self.assertEqual(verdict, Verdict.PE)
        code = '''
print("ANSWER")
        '''
        verdict = judge.get_verdict(1, 'py', code)
        self.assertEqual(verdict, Verdict.PE)
Esempio n. 3
0
    def test_custom_check(self):
        code = '''
print(5)
        '''
        check = '''
def check(a,b,c):
    return abs(float(c)-float(b)) < 1e-6
        '''
        do_problem_mock('ac test', 1, [''], ["5.0"], check)
        verdict = judge.get_verdict(1, 'py', code)
        self.assertEqual(verdict, Verdict.AC)
        do_problem_mock('ac test', 1, [''], ["5.0000001"], check)
        verdict = judge.get_verdict(1, 'py', code)
        self.assertEqual(verdict, Verdict.AC)
        do_problem_mock('ac test', 1, [''], ["5.000001"], check)
        verdict = judge.get_verdict(1, 'py', code)
        self.assertEqual(verdict, Verdict.WA)
Esempio n. 4
0
    def test_rte_python(self):
        code = '''
print(1/0)
        '''

        do_problem_mock('rte test', 1, [''], ["ANSWER"])
        verdict = judge.get_verdict(1, 'py', code)
        self.assertEqual(verdict, Verdict.RTE)
Esempio n. 5
0
    def test_wa_python(self):
        code = '''
print("WA")
        '''

        do_problem_mock('wa test', 1, [''], ["AC\n"])
        verdict = judge.get_verdict(1, 'py', code)
        self.assertEqual(verdict, Verdict.WA)
Esempio n. 6
0
    def test_ac_python(self):
        code = '''
print("AC")
        '''

        do_problem_mock('ac test', 1, [''], ['AC\n'])
        verdict = judge.get_verdict(1, 'py', code)
        self.assertEqual(verdict, Verdict.AC)
Esempio n. 7
0
    def test_je_cpp(self):
        code = '''
int main() {
    return 0;
}
        '''

        do_problem_mock('je test', 1, [], [])
        verdict = judge.get_verdict(1, 'cpp', code)
        self.assertEqual(verdict, Verdict.JE)
Esempio n. 8
0
    def test_ce_cpp(self):
        code = '''
{
xablau;;;;;
}
        '''

        do_problem_mock('ce test', 1, [''], [''])
        verdict = judge.get_verdict(1, 'cpp', code)
        self.assertEqual(verdict, Verdict.CE)
Esempio n. 9
0
    def test_tle_cpp(self):
        code = '''
#include <iostream>
#include <chrono>
#include <thread>
int main() {
    using namespace std::chrono_literals;
    std::this_thread::sleep_for(%ss);
    std::cout << std::endl;
    return 0;
}
        '''

        do_problem_mock('tle test', 1, [''], [''])
        verdict = judge.get_verdict(1, 'cpp', (code % 1.5))
        self.assertEqual(verdict, Verdict.TLE)

        verdict = judge.get_verdict(1, 'cpp', (code % 0.5))
        self.assertNotEqual(verdict, Verdict.TLE)
Esempio n. 10
0
    def test_pe_cpp(self):
        code = '''
#include <iostream>
int main() {
    std::cout << "ANSWER" << std::endl;
    return 0;
}
        '''

        do_problem_mock('pe test', 1, [''], ['ANSWER'])
        verdict = judge.get_verdict(1, 'cpp', code)
        self.assertEqual(verdict, Verdict.PE)
Esempio n. 11
0
    def test_wa_cpp(self):
        code = '''
#include <iostream>
int main() {
    std::cout << "wa pls" << std::endl;
    return 0;
}
        '''

        do_problem_mock('wa test', 1, [''], [''])
        verdict = judge.get_verdict(1, 'cpp', code)
        self.assertEqual(verdict, Verdict.WA)
Esempio n. 12
0
    def test_rte_cpp(self):
        code = '''
#include <csignal>
int main()
{
    std::raise(SIGSEGV);
    return 0;
}
        '''

        do_problem_mock('rte test', 1, [''], [''])
        verdict = judge.get_verdict(1, 'cpp', code)
        self.assertEqual(verdict, Verdict.RTE)