about summary refs log tree commit diff
path: root/users/tazjin/german-string/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'users/tazjin/german-string/src/lib.rs')
-rw-r--r--users/tazjin/german-string/src/lib.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/users/tazjin/german-string/src/lib.rs b/users/tazjin/german-string/src/lib.rs
index ed2efd3872f1..7eb9eda4e88a 100644
--- a/users/tazjin/german-string/src/lib.rs
+++ b/users/tazjin/german-string/src/lib.rs
@@ -190,9 +190,29 @@ 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);
         }