MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / bad_magic_rejected

Function bad_magic_rejected

nodedb-vector/src/mmap_segment/reader.rs:671–685  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

669
670 #[test]
671 fn bad_magic_rejected() {
672 let dir = tempfile::tempdir().unwrap();
673 let path = dir.path().join("badmagic.vseg");
674
675 let v = vec![1.0f32, 2.0];
676 write_segment(&path, 2, &[&v], &[]).unwrap();
677
678 let mut data = std::fs::read(&path).unwrap();
679 data[0] = b'X';
680 std::fs::write(&path, &data).unwrap();
681
682 let result = MmapVectorSegment::open(&path);
683 assert!(result.is_err());
684 assert_eq!(result.unwrap_err().kind(), std::io::ErrorKind::InvalidData);
685 }
686
687 #[test]
688 fn overflow_dim_count_rejected() {

Callers

nothing calls this directly

Calls 6

joinMethod · 0.80
write_segmentFunction · 0.70
readFunction · 0.50
writeFunction · 0.50
openFunction · 0.50
pathMethod · 0.45

Tested by

no test coverage detected