pub struct Task {
pub tests_path: PathBuf,
pub solution_path: PathBuf,
pub time_limit: f32,
pub tests_archive_path: PathBuf,
pub cps_tests_archive_path: PathBuf,
pub get_input_file_name: Box<dyn Fn(i32, i32, i32) -> String>,
pub get_output_file_name: Box<dyn Fn(i32, i32, i32) -> String>,
/* private fields */
}
Expand description
This struct represents an entire task. You can add subtasks, partial solutions and set the time limit. Once you are done, you can create tests for the task.
Fields§
§tests_path: PathBuf
§solution_path: PathBuf
§time_limit: f32
§tests_archive_path: PathBuf
§cps_tests_archive_path: PathBuf
§get_input_file_name: Box<dyn Fn(i32, i32, i32) -> String>
§get_output_file_name: Box<dyn Fn(i32, i32, i32) -> String>
Implementations§
Source§impl Task
impl Task
Sourcepub fn new(name: &str, path: &Path) -> Self
pub fn new(name: &str, path: &Path) -> Self
This function creates a new task with the given name and path.
The path should be a relative path to the task folder in which the tests will be generated.
The solution should be at solution_path
which is path
/solution.cpp by default but can be changed.
Sourcepub fn add_subtask(&mut self, subtask: Subtask) -> usize
pub fn add_subtask(&mut self, subtask: Subtask) -> usize
This function adds a subtask to the task. The subtask must be ready as it cannot be modified after it is added to the task. The function returns the index of the subtask.
Sourcepub fn add_subtask_dependency(&mut self, subtask: usize, dependency: usize)
pub fn add_subtask_dependency(&mut self, subtask: usize, dependency: usize)
This function adds a dependency between two subtasks. A dependency means, that the first subtask must be solved before the second subtask. In practice that means that all the tests from the dependency subtask will be added before the tests from the subtask. Dependencies apply recursively but do not duplicate tests. The subtask must be added to the task before this function is called.
Sourcepub fn add_partial_solution(
&mut self,
solution_path: &str,
passes_subtasks: &[usize],
)
pub fn add_partial_solution( &mut self, solution_path: &str, passes_subtasks: &[usize], )
This function adds a partial solution to the task. A partial solution is a solution that only solves a subset of subtasks. When the task is generated, the partial solution will be run on all tests of the subtasks it solves. If the partial solution does not solve the exact subtasks it should, an error will be thrown.
Sourcepub fn create_tests(&mut self) -> Result<()>
pub fn create_tests(&mut self) -> Result<()>
This function does all the work. It builds the solution and all partial solutions, generates tests and checks them.
Sourcepub fn create_tests_no_print(&mut self) -> Result<()>
pub fn create_tests_no_print(&mut self) -> Result<()>
This is the same as create_tests
but it doesn’t print anything.
Sourcepub fn create_tests_for_cps(&mut self) -> Result<()>
pub fn create_tests_for_cps(&mut self) -> Result<()>
This also generates a CPS file.