Skip to content

Commit

Permalink
testsuite: add rust generator test
Browse files Browse the repository at this point in the history
This would have caught a failure on DMOJ#1148.
  • Loading branch information
Riolku committed Dec 27, 2023
1 parent 1806ba4 commit 87ad60e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions testsuite/rust_generator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This test checks that a generator, using rand, can be compiled and run in Rust.
14 changes: 14 additions & 0 deletions testsuite/rust_generator/generator.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use rand::{Rng, SeedableRng};

type ConcreteRng = rand_xoshiro::Xoshiro256PlusPlus;

fn main() {
let mut args = std::env::args();
args.next();
let mut rng = ConcreteRng::seed_from_u64(args.next().unwrap().parse().unwrap());

let x = rng.gen_range(0..10);
let y = rng.gen_range(0..10);
println!("{x} {y}");
eprintln!("{}", x + y);
}
5 changes: 5 additions & 0 deletions testsuite/rust_generator/init.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
generator: generator.rs
test_cases:
- {generator_args: [1], points: 10}
- {generator_args: [2], points: 10}
- {generator_args: [3], points: 30}
2 changes: 2 additions & 0 deletions testsuite/rust_generator/tests/AC/sol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x, y = map(int, input().split())
print(x + y)
5 changes: 5 additions & 0 deletions testsuite/rust_generator/tests/AC/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: PY3
time: 2
memory: 65536
source: sol.py
expect: [AC, AC, AC]

0 comments on commit 87ad60e

Please sign in to comment.