From 9d66aeb5110b45e7b5744396613f183f620f8dc9 Mon Sep 17 00:00:00 2001 From: Zixuan Chen Date: Mon, 17 Oct 2022 15:06:58 +0800 Subject: [PATCH] test: simplify proptest --- crates/loro-core/src/container/map/tests.rs | 4 +-- crates/loro-core/src/dag/test.rs | 28 ++++++++++++------- .../rle/src/rle_tree/test/notify_prop_test.rs | 3 +- .../rle/src/rle_tree/test/string_prop_test.rs | 4 +-- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/crates/loro-core/src/container/map/tests.rs b/crates/loro-core/src/container/map/tests.rs index 403ea5ba..bb56d635 100644 --- a/crates/loro-core/src/container/map/tests.rs +++ b/crates/loro-core/src/container/map/tests.rs @@ -30,8 +30,8 @@ mod map_proptest { proptest! { #[test] fn insert( - key in prop::collection::vec("[a-z]", 0..100), - value in prop::collection::vec(gen_insert_value(), 0..100) + key in prop::collection::vec("[a-z]", 0..22), + value in prop::collection::vec(gen_insert_value(), 0..22) ) { let mut loro = LoroCore::default(); let accessor = loro.store.get_accessor(); diff --git a/crates/loro-core/src/dag/test.rs b/crates/loro-core/src/dag/test.rs index 630a1458..5f96d41d 100644 --- a/crates/loro-core/src/dag/test.rs +++ b/crates/loro-core/src/dag/test.rs @@ -545,40 +545,48 @@ mod find_common_ancestors_proptest { proptest! { #[test] fn test_2dags( - before_merged_insertions in prop::collection::vec(gen_interaction(2), 0..300), - after_merged_insertions in prop::collection::vec(gen_interaction(2), 0..300) + before_merged_insertions in prop::collection::vec(gen_interaction(2), 0..100), + after_merged_insertions in prop::collection::vec(gen_interaction(2), 0..100) ) { test_single_common_ancestor(2, before_merged_insertions, after_merged_insertions)?; } #[test] fn test_4dags( - before_merged_insertions in prop::collection::vec(gen_interaction(4), 0..300), - after_merged_insertions in prop::collection::vec(gen_interaction(4), 0..300) + before_merged_insertions in prop::collection::vec(gen_interaction(4), 0..100), + after_merged_insertions in prop::collection::vec(gen_interaction(4), 0..100) ) { test_single_common_ancestor(4, before_merged_insertions, after_merged_insertions)?; } #[test] fn test_10dags( - before_merged_insertions in prop::collection::vec(gen_interaction(10), 0..300), - after_merged_insertions in prop::collection::vec(gen_interaction(10), 0..300) + before_merged_insertions in prop::collection::vec(gen_interaction(10), 0..100), + after_merged_insertions in prop::collection::vec(gen_interaction(10), 0..100) ) { test_single_common_ancestor(10, before_merged_insertions, after_merged_insertions)?; } + #[test] + fn test_mul_ancestors_5dags( + before_merged_insertions in prop::collection::vec(gen_interaction(10), 0..100), + after_merged_insertions in prop::collection::vec(gen_interaction(10), 0..100) + ) { + test_mul_ancestors::<2>(5, before_merged_insertions, after_merged_insertions)?; + } + #[test] fn test_mul_ancestors_10dags( - before_merged_insertions in prop::collection::vec(gen_interaction(10), 0..300), - after_merged_insertions in prop::collection::vec(gen_interaction(10), 0..300) + before_merged_insertions in prop::collection::vec(gen_interaction(10), 0..100), + after_merged_insertions in prop::collection::vec(gen_interaction(10), 0..100) ) { test_mul_ancestors::<3>(10, before_merged_insertions, after_merged_insertions)?; } #[test] fn test_mul_ancestors_15dags_2( - before_merged_insertions in prop::collection::vec(gen_interaction(15), 0..500), - after_merged_insertions in prop::collection::vec(gen_interaction(15), 0..500) + before_merged_insertions in prop::collection::vec(gen_interaction(15), 0..50), + after_merged_insertions in prop::collection::vec(gen_interaction(15), 0..50) ) { test_mul_ancestors::<5>(15, before_merged_insertions, after_merged_insertions)?; } diff --git a/crates/rle/src/rle_tree/test/notify_prop_test.rs b/crates/rle/src/rle_tree/test/notify_prop_test.rs index a18d5d3f..814c1a8c 100644 --- a/crates/rle/src/rle_tree/test/notify_prop_test.rs +++ b/crates/rle/src/rle_tree/test/notify_prop_test.rs @@ -1,4 +1,3 @@ - use proptest::prop_compose; use rand::{rngs::StdRng, SeedableRng}; @@ -343,7 +342,7 @@ mod notify_proptest { proptest! { #[test] fn test_notify( - interactions in prop::collection::vec(gen_interaction(), 1..1000), + interactions in prop::collection::vec(gen_interaction(), 1..100), ) { test(&interactions); } diff --git a/crates/rle/src/rle_tree/test/string_prop_test.rs b/crates/rle/src/rle_tree/test/string_prop_test.rs index 727eb8ff..aaac112f 100644 --- a/crates/rle/src/rle_tree/test/string_prop_test.rs +++ b/crates/rle/src/rle_tree/test/string_prop_test.rs @@ -86,7 +86,7 @@ fn basic_string_op() { fn issue_0() { let mut tree: RleTree = RleTree::default(); let insert_keys = "0123456789abcdefghijklmnopq"; - for i in 0..(1e6 as usize) { + for i in 0..(1e5 as usize) { let start = i % insert_keys.len(); if i % 3 == 0 && tree.len() > 0 { let start = i % tree.len(); @@ -319,7 +319,7 @@ mod string_proptest { proptest! { #[test] fn test_tree_string_op_the_same( - interactions in prop::collection::vec(gen_interaction(), 1..100), + interactions in prop::collection::vec(gen_interaction(), 1..50), ) { run_test(interactions); }