diff --git a/test/problems/skel/generators/generators.yaml b/test/problems/skel/generators/generators.yaml index 8072671a..968d5d73 100644 --- a/test/problems/skel/generators/generators.yaml +++ b/test/problems/skel/generators/generators.yaml @@ -1,4 +1,4 @@ -solution: /submissions/accepted/hello.cpp +solution: /submissions/accepted/hello.py #visualizer: /visualizers/asy.sh # By default, generated files are not ignored. #gitignore_generated: false diff --git a/test/problems/skel/input_validators/input_validator.cpp b/test/problems/skel/input_validators/input_validator.cpp deleted file mode 100644 index 2ebceb44..00000000 --- a/test/problems/skel/input_validators/input_validator.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -int main(int argc, char *argv[]) { - int n; - std::cin >> n; - return 0 <= n && n < 1000000 ? 42 : 43; -} diff --git a/test/problems/skel/input_validators/input_validator.py b/test/problems/skel/input_validators/input_validator.py new file mode 100644 index 00000000..bf52c8c4 --- /dev/null +++ b/test/problems/skel/input_validators/input_validator.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +try: + if 0 <= int(input()) < 1_000_000: + exit(42) + else: + print("Out of range") + exit(43) +except Exception as e: + print(e) + exit(43) diff --git a/test/problems/skel/output_validators/output_validator.cpp b/test/problems/skel/output_validators/output_validator.cpp deleted file mode 100644 index 55af96d4..00000000 --- a/test/problems/skel/output_validators/output_validator.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -int main(int argc, char *argv[]) { - std::ifstream team_ans(argv[2]); - - double answer; - return (team_ans >> answer) ? 42 : 43; -} diff --git a/test/problems/skel/output_validators/output_validator.py b/test/problems/skel/output_validators/output_validator.py new file mode 100644 index 00000000..fdf806a7 --- /dev/null +++ b/test/problems/skel/output_validators/output_validator.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +import math +import sys + +try: + # Do not use the default_output_validator.cpp, because it's wasteful to compile it for every test + if math.isclose( + 4 * float(open(sys.argv[1]).read()) ** 0.5, + float(open(sys.argv[2]).read()), + rel_tol=1e-6, + abs_tol=1e-6, + ): + exit(42) + else: + print("WA") + exit(43) +except Exception as e: + print(e) + exit(43) diff --git a/test/problems/skel/problem.yaml b/test/problems/skel/problem.yaml index 4112b4bc..099b9f31 100644 --- a/test/problems/skel/problem.yaml +++ b/test/problems/skel/problem.yaml @@ -8,7 +8,7 @@ uuid: 8ee7605a-9391-8727-1ee4-61028b8de953 license: cc by-sa rights_owner: author # 'default', 'custom', or 'custom interactive' -validation: default +validation: custom # Do not use the default_output_validator.cpp, because it's wasteful to compile it for every test # One or more of: # case_sensitive @@ -16,7 +16,7 @@ validation: default # float_absolute_tolerance eps # float_relative_tolerance eps # float_tolerance eps -validator_flags: float_tolerance 1e-6 +#validator_flags: # To change the time limit factors for problemtools/Kattis, use: limits: diff --git a/test/problems/skel/submissions/accepted/hello.cpp b/test/problems/skel/submissions/accepted/hello.cpp deleted file mode 100644 index 3d72cc78..00000000 --- a/test/problems/skel/submissions/accepted/hello.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include -using namespace std; - -int main() { - int n; - cin >> n; - cout << fixed << setprecision(10) << 4*sqrt(n) << endl; - return 0; -} diff --git a/test/problems/skel/submissions/accepted/hello.py b/test/problems/skel/submissions/accepted/hello.py new file mode 100644 index 00000000..f83966f3 --- /dev/null +++ b/test/problems/skel/submissions/accepted/hello.py @@ -0,0 +1,2 @@ +#!/usr/bin/env python3 +print(4 * int(input()) ** 0.5) diff --git a/test/test_unit.py b/test/test_unit.py index a3662980..947901f9 100644 --- a/test/test_unit.py +++ b/test/test_unit.py @@ -30,9 +30,9 @@ def setup_skel_problem(request): @pytest.mark.usefixtures('setup_skel_problem') class TestUnit: def test_memory(self): - shutil.copy('submissions/accepted/hello.cpp', 'submissions/run_time_error/hello.cpp') + shutil.copy('submissions/accepted/hello.py', 'submissions/run_time_error/hello.py') os.system( - 'sed -i "s/cin >> n/auto huge = new int[100000000]; cin >> huge[42]; n = huge[42]/" submissions/run_time_error/hello.cpp' + 'sed -i "s/print/list(range(int(1e8)));print/" submissions/run_time_error/hello.py' ) tools.test('run --no-generate -m 256'.split())