From: Nicolas Patry Date: Thu, 6 Apr 2023 08:27:13 +0000 (+0200) Subject: Adding last missing test for validate. (#225) X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=ca15ad0d5e51ecd5ce845bfa50b36a6c57c964e1;p=safetensors.git Adding last missing test for validate. (#225) --- diff --git a/safetensors/src/tensor.rs b/safetensors/src/tensor.rs index bb6ff60..c89d640 100644 --- a/safetensors/src/tensor.rs +++ b/safetensors/src/tensor.rs @@ -1082,6 +1082,17 @@ mod tests { assert_eq!(tensor.data(), b""); } + #[test] + fn test_invalid_info() { + let serialized = b"<\x00\x00\x00\x00\x00\x00\x00{\"test\":{\"dtype\":\"I32\",\"shape\":[2,2],\"data_offsets\":[0, 4]}}"; + match SafeTensors::deserialize(serialized) { + Err(SafeTensorError::TensorInvalidInfo) => { + // Yes we have the correct error + } + _ => panic!("This should not be able to be deserialized"), + } + } + #[test] fn test_validation_overflow() { // u64::MAX = 18_446_744_073_709_551_615u64