gameServer2/src/protocol/test.rs
changeset 13442 a0c3431f60ac
parent 13438 fb104e150878
child 13444 c4f917c6be51
equal deleted inserted replaced
13441:e4fbf2ec9f8a 13442:a0c3431f60ac
    44 
    44 
    45 /// Wrapper type for generating non-empty strings
    45 /// Wrapper type for generating non-empty strings
    46 #[derive(Debug)]
    46 #[derive(Debug)]
    47 struct Ascii(String);
    47 struct Ascii(String);
    48 
    48 
    49 struct AsciiValueTree(RegexGeneratorValueTree<String>);
       
    50 
       
    51 impl ValueTree for AsciiValueTree {
       
    52     type Value = Ascii;
       
    53 
       
    54     fn current(&self) -> Self::Value { Ascii(self.0.current()) }
       
    55     fn simplify(&mut self) -> bool { self.0.simplify() }
       
    56     fn complicate(&mut self) -> bool { self.0.complicate() }
       
    57 }
       
    58 
       
    59 impl Arbitrary for Ascii {
    49 impl Arbitrary for Ascii {
    60     type Parameters = <String as Arbitrary>::Parameters;
    50     type Parameters = <String as Arbitrary>::Parameters;
    61 
    51 
    62     fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
    52     fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
    63         any_with::<String>(args)
    53         any_with::<String>(args)
    69             .prop_map(Ascii)
    59             .prop_map(Ascii)
    70             .boxed()
    60             .boxed()
    71     }
    61     }
    72 
    62 
    73     type Strategy = BoxedStrategy<Ascii>;
    63     type Strategy = BoxedStrategy<Ascii>;
    74     type ValueTree = Box<dyn ValueTree<Value = Ascii>>;
       
    75 }
    64 }
    76 
    65 
    77 pub fn gen_proto_msg() -> BoxedStrategy<HWProtocolMessage> where {
    66 pub fn gen_proto_msg() -> BoxedStrategy<HWProtocolMessage> where {
    78     let res = (0..58).no_shrink().prop_flat_map(|i| {
    67     let res = (0..58).no_shrink().prop_flat_map(|i| {
    79         proto_msg_match!(i, def = Malformed,
    68         proto_msg_match!(i, def = Malformed,