rust/hedgewars-server/src/protocol/test.rs
changeset 14816 add191d825f4
parent 14804 b3adc030104b
child 15095 c5a6e8566425
equal deleted inserted replaced
14815:fc2cfec95d86 14816:add191d825f4
   127                     hog(6),
   127                     hog(6),
   128                     hog(7),
   128                     hog(7),
   129                     hog(8),
   129                     hog(8),
   130                 ];
   130                 ];
   131                 TeamInfo {
   131                 TeamInfo {
       
   132                     owner: String::new(),
   132                     name,
   133                     name,
   133                     color,
   134                     color,
   134                     grave,
   135                     grave,
   135                     fort,
   136                     fort,
   136                     voice_pack,
   137                     voice_pack,
   148 
   149 
   149 impl Arbitrary for ServerVar {
   150 impl Arbitrary for ServerVar {
   150     type Parameters = ();
   151     type Parameters = ();
   151 
   152 
   152     fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
   153     fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
   153         (0..2)
   154         (0..=2)
   154             .no_shrink()
   155             .no_shrink()
   155             .prop_flat_map(|i| {
   156             .prop_flat_map(|i| {
   156                 proto_msg_match!(i, def = ServerVar::LatestProto(0),
   157                 proto_msg_match!(i, def = ServerVar::LatestProto(0),
   157                     0 => MOTDNew(Ascii),
   158                     0 => MOTDNew(Ascii),
   158                     1 => MOTDOld(Ascii),
   159                     1 => MOTDOld(Ascii),
   164 
   165 
   165     type Strategy = BoxedStrategy<ServerVar>;
   166     type Strategy = BoxedStrategy<ServerVar>;
   166 }
   167 }
   167 
   168 
   168 pub fn gen_proto_msg() -> BoxedStrategy<HWProtocolMessage> where {
   169 pub fn gen_proto_msg() -> BoxedStrategy<HWProtocolMessage> where {
   169     let res = (0..58).no_shrink().prop_flat_map(|i| {
   170     let res = (0..=55).no_shrink().prop_flat_map(|i| {
   170         proto_msg_match!(i, def = Malformed,
   171         proto_msg_match!(i, def = Ping,
   171             0 => Ping(),
   172             0 => Ping(),
   172             1 => Pong(),
   173             1 => Pong(),
   173             2 => Quit(Option<Ascii>),
   174             2 => Quit(Option<Ascii>),
   174             //3 => Cmd
       
   175             4 => Global(Ascii),
   175             4 => Global(Ascii),
   176             5 => Watch(Ascii),
   176             5 => Watch(u32),
   177             6 => ToggleServerRegisteredOnly(),
   177             6 => ToggleServerRegisteredOnly(),
   178             7 => SuperPower(),
   178             7 => SuperPower(),
   179             8 => Info(Ascii),
   179             8 => Info(Ascii),
   180             9 => Nick(Ascii),
   180             9 => Nick(Ascii),
   181             10 => Proto(u16),
   181             10 => Proto(u16),
   221             50 => Vote(bool),
   221             50 => Vote(bool),
   222             51 => ForceVote(bool),
   222             51 => ForceVote(bool),
   223             52 => Save(Ascii, Ascii),
   223             52 => Save(Ascii, Ascii),
   224             53 => Delete(Ascii),
   224             53 => Delete(Ascii),
   225             54 => SaveRoom(Ascii),
   225             54 => SaveRoom(Ascii),
   226             55 => LoadRoom(Ascii),
   226             55 => LoadRoom(Ascii)
   227             56 => Malformed(),
       
   228             57 => Empty()
       
   229         )
   227         )
   230     });
   228     });
   231     res.boxed()
   229     res.boxed()
   232 }
   230 }