|
|
@ -4,14 +4,13 @@ use bst_rs::{BinarySearchTree, IterativeBST};
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn successfully_insert_elements_into_bst() {
|
|
|
|
fn successfully_insert_elements_into_bst() {
|
|
|
|
let mut expected_bst = IterativeBST::empty();
|
|
|
|
let mut expected_bst = IterativeBST::new();
|
|
|
|
expected_bst.insert(-1);
|
|
|
|
|
|
|
|
expected_bst.insert(0);
|
|
|
|
expected_bst.insert(0);
|
|
|
|
expected_bst.insert(1);
|
|
|
|
expected_bst.insert(1);
|
|
|
|
expected_bst.insert(2);
|
|
|
|
expected_bst.insert(2);
|
|
|
|
expected_bst.insert(-20);
|
|
|
|
expected_bst.insert(-20);
|
|
|
|
|
|
|
|
|
|
|
|
let mut actual_bst = IterativeBST::new(-1);
|
|
|
|
let mut actual_bst = IterativeBST::new();
|
|
|
|
actual_bst.insert(0);
|
|
|
|
actual_bst.insert(0);
|
|
|
|
actual_bst.insert(1);
|
|
|
|
actual_bst.insert(1);
|
|
|
|
actual_bst.insert(1);
|
|
|
|
actual_bst.insert(1);
|
|
|
@ -19,12 +18,12 @@ fn successfully_insert_elements_into_bst() {
|
|
|
|
actual_bst.insert(-20);
|
|
|
|
actual_bst.insert(-20);
|
|
|
|
|
|
|
|
|
|
|
|
assert_eq!(actual_bst, expected_bst);
|
|
|
|
assert_eq!(actual_bst, expected_bst);
|
|
|
|
assert_eq!(actual_bst.size(), 5);
|
|
|
|
assert_eq!(actual_bst.size(), 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn check_if_bst_is_empty() {
|
|
|
|
fn check_if_bst_is_empty() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
assert!(bst.is_empty());
|
|
|
|
assert!(bst.is_empty());
|
|
|
|
|
|
|
|
|
|
|
|
bst.insert(1);
|
|
|
|
bst.insert(1);
|
|
|
@ -33,7 +32,7 @@ fn check_if_bst_is_empty() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn check_if_bst_contains_elements() {
|
|
|
|
fn check_if_bst_contains_elements() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
assert!(!bst.contains(&10));
|
|
|
|
assert!(!bst.contains(&10));
|
|
|
|
|
|
|
|
|
|
|
|
bst.insert(1);
|
|
|
|
bst.insert(1);
|
|
|
@ -46,7 +45,7 @@ fn check_if_bst_contains_elements() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn successfully_remove_root_node_from_bst() {
|
|
|
|
fn successfully_remove_root_node_from_bst() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
bst.insert(0);
|
|
|
|
bst.insert(0);
|
|
|
|
|
|
|
|
|
|
|
|
bst.remove(&0);
|
|
|
|
bst.remove(&0);
|
|
|
@ -57,11 +56,11 @@ fn successfully_remove_root_node_from_bst() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn successfully_remove_leaf_node() {
|
|
|
|
fn successfully_remove_leaf_node() {
|
|
|
|
let mut expected_bst = IterativeBST::empty();
|
|
|
|
let mut expected_bst = IterativeBST::new();
|
|
|
|
expected_bst.insert(5);
|
|
|
|
expected_bst.insert(5);
|
|
|
|
expected_bst.insert(4);
|
|
|
|
expected_bst.insert(4);
|
|
|
|
expected_bst.insert(6);
|
|
|
|
expected_bst.insert(6);
|
|
|
|
let mut actual_bst = IterativeBST::empty();
|
|
|
|
let mut actual_bst = IterativeBST::new();
|
|
|
|
actual_bst.insert(5);
|
|
|
|
actual_bst.insert(5);
|
|
|
|
actual_bst.insert(4);
|
|
|
|
actual_bst.insert(4);
|
|
|
|
actual_bst.insert(6);
|
|
|
|
actual_bst.insert(6);
|
|
|
@ -75,12 +74,12 @@ fn successfully_remove_leaf_node() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn remove_single_right_node_with_children() {
|
|
|
|
fn remove_single_right_node_with_children() {
|
|
|
|
let mut expected_bst = IterativeBST::empty();
|
|
|
|
let mut expected_bst = IterativeBST::new();
|
|
|
|
expected_bst.insert(5);
|
|
|
|
expected_bst.insert(5);
|
|
|
|
expected_bst.insert(4);
|
|
|
|
expected_bst.insert(4);
|
|
|
|
expected_bst.insert(7);
|
|
|
|
expected_bst.insert(7);
|
|
|
|
expected_bst.insert(8);
|
|
|
|
expected_bst.insert(8);
|
|
|
|
let mut actual_bst = IterativeBST::empty();
|
|
|
|
let mut actual_bst = IterativeBST::new();
|
|
|
|
actual_bst.insert(5);
|
|
|
|
actual_bst.insert(5);
|
|
|
|
actual_bst.insert(4);
|
|
|
|
actual_bst.insert(4);
|
|
|
|
actual_bst.insert(6);
|
|
|
|
actual_bst.insert(6);
|
|
|
@ -96,12 +95,12 @@ fn remove_single_right_node_with_children() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn remove_single_left_node_with_children() {
|
|
|
|
fn remove_single_left_node_with_children() {
|
|
|
|
let mut expected_bst = IterativeBST::empty();
|
|
|
|
let mut expected_bst = IterativeBST::new();
|
|
|
|
expected_bst.insert(5);
|
|
|
|
expected_bst.insert(5);
|
|
|
|
expected_bst.insert(3);
|
|
|
|
expected_bst.insert(3);
|
|
|
|
expected_bst.insert(2);
|
|
|
|
expected_bst.insert(2);
|
|
|
|
expected_bst.insert(6);
|
|
|
|
expected_bst.insert(6);
|
|
|
|
let mut actual_bst = IterativeBST::empty();
|
|
|
|
let mut actual_bst = IterativeBST::new();
|
|
|
|
actual_bst.insert(5);
|
|
|
|
actual_bst.insert(5);
|
|
|
|
actual_bst.insert(4);
|
|
|
|
actual_bst.insert(4);
|
|
|
|
actual_bst.insert(6);
|
|
|
|
actual_bst.insert(6);
|
|
|
@ -116,12 +115,12 @@ fn remove_single_left_node_with_children() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn remove_node_with_two_children() {
|
|
|
|
fn remove_node_with_two_children() {
|
|
|
|
let mut expected_bst = IterativeBST::empty();
|
|
|
|
let mut expected_bst = IterativeBST::new();
|
|
|
|
expected_bst.insert(10);
|
|
|
|
expected_bst.insert(10);
|
|
|
|
expected_bst.insert(3);
|
|
|
|
expected_bst.insert(3);
|
|
|
|
expected_bst.insert(8);
|
|
|
|
expected_bst.insert(8);
|
|
|
|
expected_bst.insert(15);
|
|
|
|
expected_bst.insert(15);
|
|
|
|
let mut actual_bst = IterativeBST::empty();
|
|
|
|
let mut actual_bst = IterativeBST::new();
|
|
|
|
actual_bst.insert(10);
|
|
|
|
actual_bst.insert(10);
|
|
|
|
actual_bst.insert(5);
|
|
|
|
actual_bst.insert(5);
|
|
|
|
actual_bst.insert(8);
|
|
|
|
actual_bst.insert(8);
|
|
|
@ -135,14 +134,14 @@ fn remove_node_with_two_children() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn does_not_fail_when_removing_non_existing_element() {
|
|
|
|
fn does_not_fail_when_removing_non_existing_element() {
|
|
|
|
let mut expected_bst = IterativeBST::empty();
|
|
|
|
let mut expected_bst = IterativeBST::new();
|
|
|
|
expected_bst.insert(10);
|
|
|
|
expected_bst.insert(10);
|
|
|
|
expected_bst.insert(5);
|
|
|
|
expected_bst.insert(5);
|
|
|
|
expected_bst.insert(8);
|
|
|
|
expected_bst.insert(8);
|
|
|
|
expected_bst.insert(3);
|
|
|
|
expected_bst.insert(3);
|
|
|
|
expected_bst.insert(15);
|
|
|
|
expected_bst.insert(15);
|
|
|
|
|
|
|
|
|
|
|
|
let mut actual_bst = IterativeBST::empty();
|
|
|
|
let mut actual_bst = IterativeBST::new();
|
|
|
|
actual_bst.insert(10);
|
|
|
|
actual_bst.insert(10);
|
|
|
|
actual_bst.insert(5);
|
|
|
|
actual_bst.insert(5);
|
|
|
|
actual_bst.insert(8);
|
|
|
|
actual_bst.insert(8);
|
|
|
@ -157,7 +156,7 @@ fn does_not_fail_when_removing_non_existing_element() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn retrieve_element() {
|
|
|
|
fn retrieve_element() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
bst.insert(5);
|
|
|
|
bst.insert(5);
|
|
|
|
bst.insert(10);
|
|
|
|
bst.insert(10);
|
|
|
|
|
|
|
|
|
|
|
@ -170,11 +169,11 @@ fn retrieve_element() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn retrieve_element_as_mut_and_modify_bst() {
|
|
|
|
fn retrieve_element_as_mut_and_modify_bst() {
|
|
|
|
let mut expected_bst = IterativeBST::empty();
|
|
|
|
let mut expected_bst = IterativeBST::new();
|
|
|
|
expected_bst.insert(10);
|
|
|
|
expected_bst.insert(10);
|
|
|
|
expected_bst.insert(2);
|
|
|
|
expected_bst.insert(2);
|
|
|
|
|
|
|
|
|
|
|
|
let mut actual_bst = IterativeBST::empty();
|
|
|
|
let mut actual_bst = IterativeBST::new();
|
|
|
|
actual_bst.insert(10);
|
|
|
|
actual_bst.insert(10);
|
|
|
|
actual_bst.insert(5);
|
|
|
|
actual_bst.insert(5);
|
|
|
|
|
|
|
|
|
|
|
@ -186,7 +185,7 @@ fn retrieve_element_as_mut_and_modify_bst() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn get_min_from_bst() {
|
|
|
|
fn get_min_from_bst() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
assert_eq!(bst.min(), None);
|
|
|
|
assert_eq!(bst.min(), None);
|
|
|
|
|
|
|
|
|
|
|
|
bst.insert(5);
|
|
|
|
bst.insert(5);
|
|
|
@ -199,7 +198,7 @@ fn get_min_from_bst() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn get_max_from_bst() {
|
|
|
|
fn get_max_from_bst() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
assert_eq!(bst.max(), None);
|
|
|
|
assert_eq!(bst.max(), None);
|
|
|
|
|
|
|
|
|
|
|
|
bst.insert(5);
|
|
|
|
bst.insert(5);
|
|
|
@ -212,7 +211,7 @@ fn get_max_from_bst() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn remove_min_from_bst() {
|
|
|
|
fn remove_min_from_bst() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
assert_eq!(bst.remove_min(), None);
|
|
|
|
assert_eq!(bst.remove_min(), None);
|
|
|
|
|
|
|
|
|
|
|
|
bst.insert(5);
|
|
|
|
bst.insert(5);
|
|
|
@ -231,7 +230,7 @@ fn remove_min_from_bst() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn remove_max_from_bst() {
|
|
|
|
fn remove_max_from_bst() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
assert_eq!(bst.remove_max(), None);
|
|
|
|
assert_eq!(bst.remove_max(), None);
|
|
|
|
|
|
|
|
|
|
|
|
bst.insert(5);
|
|
|
|
bst.insert(5);
|
|
|
@ -250,7 +249,7 @@ fn remove_max_from_bst() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn pre_order_iter() {
|
|
|
|
fn pre_order_iter() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(4);
|
|
|
|
bst.insert(4);
|
|
|
|
bst.insert(5);
|
|
|
|
bst.insert(5);
|
|
|
@ -281,7 +280,7 @@ fn pre_order_iter() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn in_order_iter() {
|
|
|
|
fn in_order_iter() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(4);
|
|
|
|
bst.insert(4);
|
|
|
|
bst.insert(5);
|
|
|
|
bst.insert(5);
|
|
|
@ -312,7 +311,7 @@ fn in_order_iter() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn post_order_iter() {
|
|
|
|
fn post_order_iter() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(4);
|
|
|
|
bst.insert(4);
|
|
|
|
bst.insert(5);
|
|
|
|
bst.insert(5);
|
|
|
@ -344,10 +343,10 @@ fn post_order_iter() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn into_pre_order_iter() {
|
|
|
|
fn into_pre_order_iter() {
|
|
|
|
let mut iter: IntoIter<i32> = IterativeBST::empty().into_pre_order_iter();
|
|
|
|
let mut iter: IntoIter<i32> = IterativeBST::new().into_pre_order_iter();
|
|
|
|
assert_eq!(iter.next(), None);
|
|
|
|
assert_eq!(iter.next(), None);
|
|
|
|
|
|
|
|
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(4);
|
|
|
|
bst.insert(4);
|
|
|
|
bst.insert(5);
|
|
|
|
bst.insert(5);
|
|
|
@ -366,7 +365,7 @@ fn into_pre_order_iter() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn into_in_order_iter() {
|
|
|
|
fn into_in_order_iter() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(4);
|
|
|
|
bst.insert(4);
|
|
|
|
bst.insert(5);
|
|
|
|
bst.insert(5);
|
|
|
@ -385,7 +384,7 @@ fn into_in_order_iter() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn into_post_order_iter() {
|
|
|
|
fn into_post_order_iter() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(4);
|
|
|
|
bst.insert(4);
|
|
|
|
bst.insert(5);
|
|
|
|
bst.insert(5);
|
|
|
@ -404,7 +403,7 @@ fn into_post_order_iter() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn get_sorted_vec() {
|
|
|
|
fn get_sorted_vec() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(4);
|
|
|
|
bst.insert(4);
|
|
|
|
bst.insert(5);
|
|
|
|
bst.insert(5);
|
|
|
@ -416,7 +415,7 @@ fn get_sorted_vec() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn bst_into_sorted_vec() {
|
|
|
|
fn bst_into_sorted_vec() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(4);
|
|
|
|
bst.insert(4);
|
|
|
|
bst.insert(5);
|
|
|
|
bst.insert(5);
|
|
|
@ -428,7 +427,7 @@ fn bst_into_sorted_vec() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn get_pre_order_vec() {
|
|
|
|
fn get_pre_order_vec() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
assert!(bst.pre_order_vec().is_empty());
|
|
|
|
assert!(bst.pre_order_vec().is_empty());
|
|
|
|
|
|
|
|
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(3);
|
|
|
@ -442,7 +441,7 @@ fn get_pre_order_vec() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn get_in_order_vec() {
|
|
|
|
fn get_in_order_vec() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
assert!(bst.in_order_vec().is_empty());
|
|
|
|
assert!(bst.in_order_vec().is_empty());
|
|
|
|
|
|
|
|
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(3);
|
|
|
@ -456,7 +455,7 @@ fn get_in_order_vec() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn get_post_order_vec() {
|
|
|
|
fn get_post_order_vec() {
|
|
|
|
let mut bst = IterativeBST::empty();
|
|
|
|
let mut bst = IterativeBST::new();
|
|
|
|
assert!(bst.post_order_vec().is_empty());
|
|
|
|
assert!(bst.post_order_vec().is_empty());
|
|
|
|
|
|
|
|
|
|
|
|
bst.insert(3);
|
|
|
|
bst.insert(3);
|
|
|
@ -469,7 +468,7 @@ fn get_post_order_vec() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn create_bst_from_vec() {
|
|
|
|
fn create_bst_from_vec() {
|
|
|
|
let mut expected_bst = IterativeBST::empty();
|
|
|
|
let mut expected_bst = IterativeBST::new();
|
|
|
|
expected_bst.insert(10);
|
|
|
|
expected_bst.insert(10);
|
|
|
|
expected_bst.insert(20);
|
|
|
|
expected_bst.insert(20);
|
|
|
|
expected_bst.insert(5);
|
|
|
|
expected_bst.insert(5);
|
|
|
@ -482,7 +481,7 @@ fn create_bst_from_vec() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn create_bst_from_slice() {
|
|
|
|
fn create_bst_from_slice() {
|
|
|
|
let mut expected_bst = IterativeBST::empty();
|
|
|
|
let mut expected_bst = IterativeBST::new();
|
|
|
|
expected_bst.insert(10);
|
|
|
|
expected_bst.insert(10);
|
|
|
|
expected_bst.insert(20);
|
|
|
|
expected_bst.insert(20);
|
|
|
|
expected_bst.insert(5);
|
|
|
|
expected_bst.insert(5);
|
|
|
@ -495,7 +494,7 @@ fn create_bst_from_slice() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn create_bst_from_into_vec() {
|
|
|
|
fn create_bst_from_into_vec() {
|
|
|
|
let mut expected_bst = IterativeBST::empty();
|
|
|
|
let mut expected_bst = IterativeBST::new();
|
|
|
|
expected_bst.insert(10);
|
|
|
|
expected_bst.insert(10);
|
|
|
|
expected_bst.insert(20);
|
|
|
|
expected_bst.insert(20);
|
|
|
|
expected_bst.insert(5);
|
|
|
|
expected_bst.insert(5);
|
|
|
@ -509,14 +508,14 @@ fn create_bst_from_into_vec() {
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn extend_bst_from_iter() {
|
|
|
|
fn extend_bst_from_iter() {
|
|
|
|
let vec = vec![8, 1, 10];
|
|
|
|
let vec = vec![8, 1, 10];
|
|
|
|
let mut expected_bst = IterativeBST::empty();
|
|
|
|
let mut expected_bst = IterativeBST::new();
|
|
|
|
expected_bst.insert(3);
|
|
|
|
expected_bst.insert(3);
|
|
|
|
expected_bst.insert(2);
|
|
|
|
expected_bst.insert(2);
|
|
|
|
expected_bst.insert(5);
|
|
|
|
expected_bst.insert(5);
|
|
|
|
expected_bst.insert(8);
|
|
|
|
expected_bst.insert(8);
|
|
|
|
expected_bst.insert(1);
|
|
|
|
expected_bst.insert(1);
|
|
|
|
expected_bst.insert(10);
|
|
|
|
expected_bst.insert(10);
|
|
|
|
let mut actual_bst = IterativeBST::empty();
|
|
|
|
let mut actual_bst = IterativeBST::new();
|
|
|
|
actual_bst.insert(3);
|
|
|
|
actual_bst.insert(3);
|
|
|
|
actual_bst.insert(2);
|
|
|
|
actual_bst.insert(2);
|
|
|
|
actual_bst.insert(5);
|
|
|
|
actual_bst.insert(5);
|
|
|
@ -529,7 +528,7 @@ fn extend_bst_from_iter() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn create_bst_from_iter() {
|
|
|
|
fn create_bst_from_iter() {
|
|
|
|
let mut expected_bst = IterativeBST::empty();
|
|
|
|
let mut expected_bst = IterativeBST::new();
|
|
|
|
expected_bst.insert(3);
|
|
|
|
expected_bst.insert(3);
|
|
|
|
expected_bst.insert(2);
|
|
|
|
expected_bst.insert(2);
|
|
|
|
expected_bst.insert(5);
|
|
|
|
expected_bst.insert(5);
|
|
|
@ -544,7 +543,7 @@ fn create_bst_from_iter() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn clone_bst() {
|
|
|
|
fn clone_bst() {
|
|
|
|
let mut expected_bst = IterativeBST::empty();
|
|
|
|
let mut expected_bst = IterativeBST::new();
|
|
|
|
expected_bst.insert(3);
|
|
|
|
expected_bst.insert(3);
|
|
|
|
expected_bst.insert(2);
|
|
|
|
expected_bst.insert(2);
|
|
|
|
expected_bst.insert(5);
|
|
|
|
expected_bst.insert(5);
|
|
|
@ -559,10 +558,10 @@ fn clone_bst() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn clone_into_another_bst() {
|
|
|
|
fn clone_into_another_bst() {
|
|
|
|
let mut actual_bst = IterativeBST::empty();
|
|
|
|
let mut actual_bst = IterativeBST::new();
|
|
|
|
actual_bst.insert(3);
|
|
|
|
actual_bst.insert(3);
|
|
|
|
actual_bst.insert(2);
|
|
|
|
actual_bst.insert(2);
|
|
|
|
let mut expected_bst = IterativeBST::empty();
|
|
|
|
let mut expected_bst = IterativeBST::new();
|
|
|
|
expected_bst.insert(3);
|
|
|
|
expected_bst.insert(3);
|
|
|
|
expected_bst.insert(2);
|
|
|
|
expected_bst.insert(2);
|
|
|
|
expected_bst.insert(5);
|
|
|
|
expected_bst.insert(5);
|
|
|
|