()
| 340 | |
| 341 | #[test] |
| 342 | fn insert_and_search() { |
| 343 | let mut idx = FlatIndex::new(3, DistanceMetric::L2); |
| 344 | for i in 0..100u32 { |
| 345 | idx.insert(vec![i as f32, 0.0, 0.0]); |
| 346 | } |
| 347 | assert_eq!(idx.len(), 100); |
| 348 | assert_eq!(idx.live_count(), 100); |
| 349 | |
| 350 | let results = idx.search(&[50.0, 0.0, 0.0], 3); |
| 351 | assert_eq!(results.len(), 3); |
| 352 | assert_eq!(results[0].id, 50); |
| 353 | assert!(results[0].distance < 0.01); |
| 354 | } |
| 355 | |
| 356 | #[test] |
| 357 | fn delete_excludes_from_search() { |