use super::*;
struct StubDataSource;
impl DataSource for StubDataSource {
fn generate(&self, _schema: &Value) -> Result<Value, DataSourceError> {
unimplemented!()
}
fn start_span(&self, _label: u64) -> Result<(), DataSourceError> {
unimplemented!()
}
fn stop_span(&self, _discard: bool) -> Result<(), DataSourceError> {
unimplemented!()
}
fn new_collection(
&self,
_min_size: u64,
_max_size: Option<u64>,
) -> Result<i64, DataSourceError> {
unimplemented!()
}
fn collection_more(&self, _collection_id: i64) -> Result<bool, DataSourceError> {
unimplemented!()
}
fn collection_reject(
&self,
_collection_id: i64,
_why: Option<&str>,
) -> Result<(), DataSourceError> {
unimplemented!()
}
fn new_pool(&self) -> Result<i64, DataSourceError> {
unimplemented!()
}
fn pool_add(&self, _pool_id: i64) -> Result<i64, DataSourceError> {
unimplemented!()
}
fn pool_generate(&self, _pool_id: i64, _consume: bool) -> Result<i64, DataSourceError> {
unimplemented!()
}
fn target_observation(&self, _score: f64, _label: &str) {
unimplemented!()
}
fn mark_complete(&self, _result: &crate::backend::TestCaseResult) {
unimplemented!()
}
}
fn emitting_test_case() -> TestCase {
TestCase::new(Box::new(StubDataSource), true, Mode::TestRun, false)
}
#[test]
fn debug_is_non_exhaustive() {
let tc = emitting_test_case();
assert_eq!(format!("{:?}", tc), "TestCase { .. }");
}
#[test]
fn repeatable_display_name_skips_a_taken_name() {
let tc = emitting_test_case();
tc.record_named_draw(&false, "x_1", false);
tc.record_named_draw(&false, "x", true);
tc.record_named_draw(&false, "x", true);
let mut names: Vec<String> = tc.with_shared(|shared| {
shared
.draw_state
.allocated_display_names
.iter()
.cloned()
.collect()
});
names.sort();
assert_eq!(names, vec!["x_1", "x_2", "x_3"]);
}