Skip to content

Commit cc641b3

Browse files
Riolkukiritofeng
authored andcommitted
testsuite: add rust generator test
This would have caught a failure on #1148.
1 parent b57fade commit cc641b3

File tree

6 files changed

+28
-1
lines changed

6 files changed

+28
-1
lines changed

testsuite/rust_bridged/tests/empty/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ language: RUST
22
time: 2
33
memory: 65536
44
source: empty.rs
5-
expect: [WA, WA]
5+
expect: WA

testsuite/rust_generator/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This test checks that a generator, using rand, can be compiled and run in Rust.

testsuite/rust_generator/generator.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use rand::{Rng, SeedableRng};
2+
3+
type ConcreteRng = rand_xoshiro::Xoshiro256PlusPlus;
4+
5+
fn main() {
6+
let mut args = std::env::args();
7+
args.next();
8+
let mut rng = ConcreteRng::seed_from_u64(args.next().unwrap().parse().unwrap());
9+
10+
let x = rng.gen_range(0..10);
11+
let y = rng.gen_range(0..10);
12+
println!("{x} {y}");
13+
eprintln!("{}", x + y);
14+
}

testsuite/rust_generator/init.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
generator: generator.rs
2+
test_cases:
3+
- {generator_args: [1], points: 10}
4+
- {generator_args: [2], points: 10}
5+
- {generator_args: [3], points: 30}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
x, y = map(int, input().split())
2+
print(x + y)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: PY3
2+
time: 2
3+
memory: 65536
4+
source: sol.py
5+
expect: AC

0 commit comments

Comments
 (0)