@@ -1373,8 +1373,12 @@ mod tests {
1373
1373
1374
1374
let first: [ f32 ; 5 ] = [ 0.2 , 0.1 , 0.2 , 0.1 , 0.3 ] ;
1375
1375
let second: [ f32 ; 5 ] = [ 0.3 , 0.2 , 0.4 , 0.0 , 0.1 ] ;
1376
+ let too_long: [ f32 ; 6 ] = [ 0.3 , 0.2 , 0.4 , 0.0 , 0.1 , 0.1 ] ;
1377
+ let too_short: [ f32 ; 4 ] = [ 0.3 , 0.2 , 0.4 , 0.0 ] ;
1376
1378
assert ! ( index. add( 1 , & first) . is_ok( ) ) ;
1377
1379
assert ! ( index. add( 2 , & second) . is_ok( ) ) ;
1380
+ assert ! ( index. add( 3 , & too_long) . is_err( ) ) ;
1381
+ assert ! ( index. add( 4 , & too_short) . is_err( ) ) ;
1378
1382
assert_eq ! ( index. size( ) , 2 ) ;
1379
1383
1380
1384
// Test using Vec<T>
@@ -1393,6 +1397,27 @@ mod tests {
1393
1397
let result = index. get ( 1 , & mut found) ;
1394
1398
assert ! ( result. is_err( ) ) ;
1395
1399
}
1400
+ #[ test]
1401
+ fn test_search_vector ( ) {
1402
+ let mut options = IndexOptions :: default ( ) ;
1403
+ options. dimensions = 5 ;
1404
+ options. quantization = ScalarKind :: F32 ;
1405
+ let index = Index :: new ( & options) . unwrap ( ) ;
1406
+ assert ! ( index. reserve( 10 ) . is_ok( ) ) ;
1407
+
1408
+ let first: [ f32 ; 5 ] = [ 0.2 , 0.1 , 0.2 , 0.1 , 0.3 ] ;
1409
+ let second: [ f32 ; 5 ] = [ 0.3 , 0.2 , 0.4 , 0.0 , 0.1 ] ;
1410
+ let too_long: [ f32 ; 6 ] = [ 0.3 , 0.2 , 0.4 , 0.0 , 0.1 , 0.1 ] ;
1411
+ let too_short: [ f32 ; 4 ] = [ 0.3 , 0.2 , 0.4 , 0.0 ] ;
1412
+ assert ! ( index. add( 1 , & first) . is_ok( ) ) ;
1413
+ assert ! ( index. add( 2 , & second) . is_ok( ) ) ;
1414
+ assert_eq ! ( index. size( ) , 2 ) ;
1415
+ //assert!(index.add(3, &too_long).is_err());
1416
+ //assert!(index.add(4, &too_short).is_err());
1417
+
1418
+ assert ! ( index. search( & too_long, 1 ) . is_err( ) ) ;
1419
+ assert ! ( index. search( & too_short, 1 ) . is_err( ) ) ;
1420
+ }
1396
1421
1397
1422
#[ test]
1398
1423
fn test_add_remove_vector ( ) {
0 commit comments