()
| 13 | |
| 14 | #[test] |
| 15 | fn test_store_and_load_node() { |
| 16 | let path = PathBuf::from_str("tests/data") |
| 17 | .unwrap() |
| 18 | .join(uuid::Uuid::new_v4().to_string()) |
| 19 | .join("test.bin"); |
| 20 | fs::create_dir_all(&path.parent().unwrap()).expect("Failed to create directory"); |
| 21 | |
| 22 | let mut storage_manager: StorageManager<i32, String> = |
| 23 | StorageManager::new(path.clone()).unwrap(); |
| 24 | |
| 25 | let mut node = Node::new_leaf(0); |
| 26 | node.keys.push(1); |
| 27 | node.values.push(Some("one".to_string())); |
| 28 | |
| 29 | // Store the node |
| 30 | let offset = storage_manager.store_node(&mut node).unwrap(); |
| 31 | assert_eq!(offset, HEADER_SIZE); // Check that the node is stored at the correct offset |
| 32 | |
| 33 | // Load the node |
| 34 | let loaded_node = storage_manager.load_node(offset).unwrap(); |
| 35 | assert_eq!(loaded_node.keys, vec![1]); |
| 36 | assert_eq!(loaded_node.values, vec![Some("one".to_string())]); |
| 37 | } |
| 38 | |
| 39 | #[test] |
| 40 | fn test_store_multiple_nodes() { |
nothing calls this directly
no test coverage detected