Optimize test string generation
authoralfadur
Mon, 09 Jul 2018 20:59:08 +0300
changeset 13482 7f3289a239dd
parent 13481 8697b235f236
child 13483 e1543ad2fac9
Optimize test string generation
gameServer2/src/protocol/test.rs
--- a/gameServer2/src/protocol/test.rs	Mon Jul 09 20:31:32 2018 +0300
+++ b/gameServer2/src/protocol/test.rs	Mon Jul 09 20:59:08 2018 +0300
@@ -1,8 +1,7 @@
 use proptest::{
     test_runner::{TestRunner, Reason},
     arbitrary::{any, any_with, Arbitrary, StrategyFor},
-    strategy::{Strategy, BoxedStrategy, Just, Filter, ValueTree},
-    string::RegexGeneratorValueTree,
+    strategy::{Strategy, BoxedStrategy, Just, Map},
 };
 
 use server::coretypes::{GameCfg, TeamInfo, HedgehogInfo};
@@ -55,14 +54,7 @@
     type Parameters = <String as Arbitrary>::Parameters;
 
     fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
-        any_with::<String>(args)
-            .prop_filter("not ascii", |s| {
-                s.len() > 0 && s.is_ascii() &&
-                    s.find(|c| {
-                        ['\0', '\n', '\x20'].contains(&c)
-                    }).is_none()})
-            .prop_map(Ascii)
-            .boxed()
+        "[a-zA-Z0-9]+".prop_map(Ascii).boxed()
     }
 
     type Strategy = BoxedStrategy<Ascii>;