fix: Corrected doctests to pass

This commit is contained in:
2024-11-14 16:04:39 -07:00
parent 3e23a73f6b
commit 37d7b77f90
4 changed files with 10 additions and 9 deletions
+1
View File
@@ -8,6 +8,7 @@ authors = ["EdJoPaTo <tui-tree-widget-rust-crate@edjopato.de>", "Dark-Alex-17 <a
edition = "2021"
keywords = ["tui", "terminal", "tree", "widget", "managarr"]
categories = ["command-line-interface"]
rust-version = "1.82.0"
include = ["src/**/*", "examples/**/*", "benches/**/*", "README.md"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+1 -1
View File
@@ -74,7 +74,7 @@ fn init(criterion: &mut Criterion) {
group.bench_function("empty", |bencher| {
bencher.iter(|| {
let items = vec![];
let items = Vec::<TreeItem<String, String>>::new();
let _ = black_box(Tree::new(black_box(&items))).unwrap();
});
});
+2 -2
View File
@@ -37,7 +37,7 @@ mod tree_state;
/// # let mut terminal = Terminal::new(TestBackend::new(32, 32)).unwrap();
/// let mut state = TreeState::default();
///
/// let item = TreeItem::new_leaf("l", "leaf");
/// let item = TreeItem::new_leaf("l".to_owned(), "leaf".to_owned());
/// let items = vec![item];
///
/// terminal.draw(|frame| {
@@ -163,7 +163,7 @@ where
#[test]
#[should_panic = "duplicate identifiers"]
fn tree_new_errors_with_duplicate_identifiers() {
let item = TreeItem::new_leaf("same", "text");
let item = TreeItem::new_leaf("same".to_owned(), "text".to_owned());
let another = item.clone();
let items = [item, another];
let _ = Tree::new(&items).unwrap();
+6 -6
View File
@@ -29,8 +29,8 @@ use ratatui::text::Text;
///
/// ```
/// # use managarr_tree_widget::TreeItem;
/// let a = TreeItem::new_leaf("l", "Leaf");
/// let b = TreeItem::new("r", "Root", vec![a])?;
/// let a = TreeItem::new_leaf("l".to_owned(), "Leaf".to_owned());
/// let b = TreeItem::new("r".to_owned(), "Root".to_owned(), vec![a])?;
/// # Ok::<(), std::io::Error>(())
/// ```
#[derive(Debug, Clone)]
@@ -174,16 +174,16 @@ impl TreeItem<&'static str, String> {
#[test]
#[should_panic = "duplicate identifiers"]
fn tree_item_new_errors_with_duplicate_identifiers() {
let item = TreeItem::new_leaf("same", "text");
let item = TreeItem::new_leaf("same".to_owned(), "text".to_owned());
let another = item.clone();
TreeItem::new("root", "Root", vec![item, another]).unwrap();
TreeItem::new("root".to_owned(), "Root".to_owned(), vec![item, another]).unwrap();
}
#[test]
#[should_panic = "identifier already exists"]
fn tree_item_add_child_errors_with_duplicate_identifiers() {
let item = TreeItem::new_leaf("same", "text");
let item = TreeItem::new_leaf("same".to_owned(), "text".to_owned());
let another = item.clone();
let mut root = TreeItem::new("root", "Root", vec![item]).unwrap();
let mut root = TreeItem::new("root".to_owned(), "Root".to_owned(), vec![item]).unwrap();
root.add_child(another).unwrap();
}