-
Notifications
You must be signed in to change notification settings - Fork 0
Rust Port
The core logic of WaveTestLib is written in Rust, and it's natural to use the Rust port to write your answer checkers and interactors in Rust. The Rust implementation is maintained under src/rust directory. Without further comments, all shell commands listed in this page assume that you are in this directory.
Before build, please make sure that you have cargo installed in your environment:
cargo --versionIf not, it's recommended to install cargo through rustup, which installs the necessary Rust toolchain to build WaveTestLib. For instructions on installing rustup, please visit here.
Use the following command to build source documentation and open it in your browser:
cargo doc --openUse the following command to build the rust port of WaveTestLib into a static library:
cargo buildThe static library file will be available at target/<config>/libwave_test_lib.a. <config> will be either debug or release depending on your configuration.
You need to install the Rust port of WaveTestLib into your Rust environment before using it in your answer checker or interactor project:
cargo installThen add the following line to your Cargo.toml:
[dependencies]
wave_test_lib="0.1"And you're ready to go.
The following code is a ready-to-work version of an answer checker that compares each floating point numbers produced by the user's program against the ones in the standard answer file, with an absolute tolerance of 1e-8:
extern crate wave_test_lib;
fn main() {
let checker = wave_test_lib::Checker::new();
let std_ans = checker.std_answer();
let usr_ans = checker.user_answer();
while let Some(expected) = std_ans.read_token_as::<f64>() {
usr_ans.expect_float_eq(expected, 1e-8);
}
usr_ans.expect_eof();
}To be updated.