test(tazjin/german-string): add roundtrip proptests
Change-Id: Iee392368252d5c6e96d879b213aee34a301d13d6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12241 Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
		
							parent
							
								
									64a085cf52
								
							
						
					
					
						commit
						86f467cee6
					
				
					 1 changed files with 21 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -190,8 +190,28 @@ mod tests {
 | 
			
		|||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Test [`Eq`] implementation.
 | 
			
		||||
    proptest! {
 | 
			
		||||
        #[test]
 | 
			
		||||
        fn test_roundtrip_vec(input: Vec<u8>) {
 | 
			
		||||
            let gs = GermanString::new_transient(input.as_slice());
 | 
			
		||||
            assert_eq!(input.len(), gs.len(), "length should match");
 | 
			
		||||
 | 
			
		||||
            let out = gs.as_bytes().to_owned();
 | 
			
		||||
            assert_eq!(input, out, "roundtrip should yield same bytes");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #[test]
 | 
			
		||||
        fn test_roundtrip_string(input: String) {
 | 
			
		||||
            let gs = GermanString::new_transient(input.as_bytes());
 | 
			
		||||
            assert_eq!(input.len(), gs.len(), "length should match");
 | 
			
		||||
 | 
			
		||||
            let out = String::from_utf8(gs.as_bytes().to_owned())
 | 
			
		||||
              .expect("string should be valid after roundtrip");
 | 
			
		||||
 | 
			
		||||
            assert_eq!(input, out, "roundtrip should yield same string");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Test [`Eq`] implementation.
 | 
			
		||||
        #[test]
 | 
			
		||||
        fn test_reflexivity(x: GermanString) {
 | 
			
		||||
            prop_assert!(x == x);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue