about summary refs log tree commit diff
path: root/tvix/castore/src/proto/tests/directory.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/castore/src/proto/tests/directory.rs')
-rw-r--r--tvix/castore/src/proto/tests/directory.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/tvix/castore/src/proto/tests/directory.rs b/tvix/castore/src/proto/tests/directory.rs
index eed49b2b593c..688a50f5285e 100644
--- a/tvix/castore/src/proto/tests/directory.rs
+++ b/tvix/castore/src/proto/tests/directory.rs
@@ -61,6 +61,37 @@ fn size() {
 }
 
 #[test]
+#[cfg_attr(not(debug_assertions), ignore)]
+#[should_panic]
+fn size_unchecked_panic() {
+    let d = Directory {
+        directories: vec![DirectoryNode {
+            name: "foo".into(),
+            digest: DUMMY_DIGEST.to_vec().into(),
+            size: u32::MAX,
+        }],
+        ..Default::default()
+    };
+
+    d.size();
+}
+
+#[test]
+#[cfg_attr(debug_assertions, ignore)]
+fn size_unchecked_wrap() {
+    let d = Directory {
+        directories: vec![DirectoryNode {
+            name: "foo".into(),
+            digest: DUMMY_DIGEST.to_vec().into(),
+            size: u32::MAX,
+        }],
+        ..Default::default()
+    };
+
+    assert_eq!(d.size(), 0);
+}
+
+#[test]
 fn digest() {
     let d = Directory::default();