extern crate rand; extern crate sp_ropey; use rand::Rng; use sp_ropey::Rope; #[test] fn small_random_inserts() { let mut rng = rand::thread_rng(); let mut tree = Rope::new(); // Do a bunch of random incoherent inserts for _ in 0..(1 << 10) { let len = tree.len_chars().max(1); tree.insert(rng.gen::() % len, "Hello "); tree.insert(rng.gen::() % len, "world! "); tree.insert(rng.gen::() % len, "How are "); tree.insert(rng.gen::() % len, "you "); tree.insert(rng.gen::() % len, "doing?\r\n"); tree.insert(rng.gen::() % len, "Let's "); tree.insert(rng.gen::() % len, "keep "); tree.insert(rng.gen::() % len, "inserting "); tree.insert(rng.gen::() % len, "more "); tree.insert(rng.gen::() % len, "items.\r\n"); tree.insert(rng.gen::() % len, "こんいちは、"); tree.insert(rng.gen::() % len, "みんなさん!"); } // Make sure the tree is sound tree.assert_integrity(); tree.assert_invariants(); }