From 16fbbbd16da9a765e04646b85f7befdf60667aee Mon Sep 17 00:00:00 2001 From: timofey Date: Sun, 15 Oct 2023 12:13:37 +0000 Subject: [PATCH] `empty_has_height_0` --- src/rstd/collections/tree.rs | 26 ++++++++++++++++++++++++++ src/rstd/collections/tree/context.rs | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/rstd/collections/tree.rs b/src/rstd/collections/tree.rs index 418086b..7b86a99 100644 --- a/src/rstd/collections/tree.rs +++ b/src/rstd/collections/tree.rs @@ -231,3 +231,29 @@ impl<'a, Ctx: Context<'a>, A: MentionableBase<'a> + Clone> Clone for Tree<'a, Ct } } } + +#[cfg(test)] +mod tests { + use std::convert::Infallible; + + use crate::{ + flow::{binary::*, comparator::*}, + rstd::atomic_object::*, + testing::TestContextPlain, + }; + + use super::context::*; + + type Trees = + TreeContext2<'static, TestContextPlain, AtomicObject, DefaultComparator, Infallible>; + + fn new_trees() -> Trees { + Trees::new((DefaultComparator.into(), u64::f())) + } + + #[test] + fn empty_has_height_0() { + let trees = new_trees(); + assert_eq!(trees.height(&trees.empty()), 0); + } +} diff --git a/src/rstd/collections/tree/context.rs b/src/rstd/collections/tree/context.rs index 87afee4..1d66f6e 100644 --- a/src/rstd/collections/tree/context.rs +++ b/src/rstd/collections/tree/context.rs @@ -15,8 +15,8 @@ use super::*; pub struct TreeContext(Cl, PhantomData); impl TreeContext { - fn new(comparator: Cl) -> Self { - Self(comparator, PhantomData) + pub fn new(cl: Cl) -> Self { + Self(cl, PhantomData) } }