Example #1
0
    def test_608a_correct_cplusplus(self):
        obj = CodeforcesCLI("g++", "test_programs/608a.cpp")

        obj.file_output_name = "test_programs/608a.out"

        obj.test_cases = [['3 7\n2 1\n3 8\n5 2\n', '11\n'], ['5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n', '79\n']]
        self.assertEqual(obj.run_all_test_cases(), 0)
Example #2
0
    def test_686a(self):
        obj = CodeforcesCLI("g++", "686a.cpp")

        obj.file_name = "686a"
        obj.file_extn = ".cpp"
        obj.contest_id = "686"
        obj.problem_id = "a"

        obj.fetch_test_cases()
        valid_cases = [["5 7\n+ 5\n- 10\n- 20\n+ 40\n- 20\n", "22 1\n"], ["5 17\n- 16\n- 2\n- 98\n+ 100\n- 98\n", "3 2\n"]]
        self.assertEqual(obj.test_cases, valid_cases)
Example #3
0
    def test_661b(self):
        obj = CodeforcesCLI("g++", "661b.cpp")

        obj.file_name = "661b"
        obj.file_extn = ".cpp"
        obj.contest_id = "661"
        obj.problem_id = "b"

        obj.fetch_test_cases()
        valid_cases = [["April\n", "spring\n"], ["November\n", "autumn\n"]]
        self.assertEqual(obj.test_cases, valid_cases)
    def test_raise_exception(self):
        obj = CodeforcesCLI("g++", "test_programs/test_program.cpp", "-std=c+")
        obj.file_output_name = "test_program.out"
        obj.file_output_extn = ".out"
        self.assertRaises(RuntimeError, obj.compile)

        obj = CodeforcesCLI("g++", "test_programs/test_program", "-std=c++14")
        obj.file_output_name = "test_program.out"
        obj.file_output_extn = ".out"
        self.assertRaises(RuntimeError, obj.compile)
 def test_cplusplus_without_options(self):
     obj = CodeforcesCLI("g++", "test_programs/test_program.cpp")
     obj.file_output_name = "test_program.out"
     obj.file_output_extn = ".out"
     self.assertEqual(obj.compile(), 0)
     subprocess.call(["rm", "test_program.out"])
 def test_608a_cplusplus(self):
     obj = CodeforcesCLI("g++", "test_programs/608a.cpp")
     obj.parse_file_name()
     self.assertEqual(obj.file_name, "608a")
     self.assertEqual(obj.file_extn, "cpp")