Skip to content

Commit

Permalink
lint2
Browse files Browse the repository at this point in the history
  • Loading branch information
velicuvlad committed Feb 28, 2024
1 parent f41f0a2 commit a60633d
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions Objective-C/Tests/VectorSearchTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,16 @@ - (void) testDimensionsValidation {
AssertNotNil(config2);

[self expectException: NSInvalidArgumentException in:^{
(void) [[CBLVectorIndexConfiguration alloc] initWithExpression:@"vector" dimensions: 0 centroids: 20];
(void) [[CBLVectorIndexConfiguration alloc] initWithExpression: @"vector"
dimensions: 0
centroids: 20];
NSLog(@"Invalid Argument test for dimensions = 0");
}];

[self expectException: NSInvalidArgumentException in:^{
(void) [[CBLVectorIndexConfiguration alloc] initWithExpression:@"vector" dimensions: 2049 centroids: 20];
(void) [[CBLVectorIndexConfiguration alloc] initWithExpression: @"vector"
dimensions: 2049
centroids: 20];
NSLog(@"Invalid Argument test for dimensions = 2049");
}];
}
Expand Down Expand Up @@ -173,17 +177,17 @@ - (void) testUpdateVectorIndex {
AssertEqual(allObjects.count, 300);

// Update docs:
NSDictionary* data = [[extWordsCollection documentWithID:@"word1" error : &error] toDictionary];
CBLMutableDocument* destinationDoc = [self createDocument:@"word351" data:data];
NSDictionary* data = [[extWordsCollection documentWithID: @"word1" error : &error] toDictionary];
CBLMutableDocument* destinationDoc = [self createDocument: @"word351" data: data];
Assert([wordsCollection saveDocument: destinationDoc error: &error]);

data = [[extWordsCollection documentWithID:@"word2" error : &error] toDictionary];
destinationDoc = [self createDocument:@"word352" data:data];
data = [[extWordsCollection documentWithID: @"word2" error : &error] toDictionary];
destinationDoc = [self createDocument: @"word352" data:data];
Assert([wordsCollection saveDocument: destinationDoc error: &error]);

data = [[extWordsCollection documentWithID:@"word3" error : &error] toDictionary];
data = [[extWordsCollection documentWithID: @"word3" error : &error] toDictionary];
CBLMutableDocument* destinationDoc2 = [[wordsCollection documentWithID: @"word1" error: &error] toMutable];
[destinationDoc2 setData:data];
[destinationDoc2 setData: data];
Assert([wordsCollection saveDocument: destinationDoc2 error: &error]);

[wordsCollection deleteDocument: [wordsCollection documentWithID: @"word2" error :&error] error: &error];
Expand Down Expand Up @@ -246,7 +250,7 @@ - (void) _testCreateVectorIndexWithInvalidVectors {

auxDoc = [[collection documentWithID: @"word5" error: &error] toMutable];
[auxDoc setString: nil forKey: @"vector"];
[collection saveDocument:auxDoc error:&error];
[collection saveDocument: auxDoc error: &error];
rs = [q execute: &error];
allObjects = rs.allObjects;
AssertEqual(allObjects.count, 295);
Expand All @@ -260,7 +264,7 @@ - (void) testCreateVectorIndexUsingPredictionModel {

CBLDatabase *modelDb = [self openDBNamed: kDatabaseName error: &error];
CBLWordEmbeddingModel* model = [[CBLWordEmbeddingModel alloc] initWithDatabase: modelDb];
[CBLDatabase.prediction registerModel: model withName:@"WordEmbedding"];
[CBLDatabase.prediction registerModel: model withName: @"WordEmbedding"];

CBLVectorIndexConfiguration* config = [[CBLVectorIndexConfiguration alloc] initWithExpression: @"prediction(\"WordEmbedding\",{\"word\": word}).vector"
dimensions: 300
Expand All @@ -287,23 +291,23 @@ - (void) testCreateVectorIndexUsingPredictionModel {
AssertEqual(allObjects.count, 300);

// Create words.word301 with extwords.word1 content
NSDictionary* data = [[extWordsCollection documentWithID:@"word1" error : &error] toDictionary];
CBLMutableDocument* destinationDoc = [self createDocument:@"word301" data:data];
NSDictionary* data = [[extWordsCollection documentWithID: @"word1" error : &error] toDictionary];
CBLMutableDocument* destinationDoc = [self createDocument: @"word301" data: data];
Assert([wordsCollection saveDocument: destinationDoc error: &error]);

// Create words.word302 with extwords.word2 content
data = [[extWordsCollection documentWithID:@"word2" error : &error] toDictionary];
destinationDoc = [self createDocument:@"word302" data:data];
data = [[extWordsCollection documentWithID: @"word2" error : &error] toDictionary];
destinationDoc = [self createDocument: @"word302" data: data];
Assert([wordsCollection saveDocument: destinationDoc error: &error]);

// Update words.word1 with extwords.word3 content
data = [[extWordsCollection documentWithID:@"word3" error : &error] toDictionary];
data = [[extWordsCollection documentWithID: @"word3" error : &error] toDictionary];
CBLMutableDocument* destinationDoc2 = [[wordsCollection documentWithID: @"word1" error: &error] toMutable];
[destinationDoc2 setData:data];
[destinationDoc2 setData: data];
Assert([wordsCollection saveDocument: destinationDoc2 error: &error]);

// Delete words.word2
[wordsCollection deleteDocument: [wordsCollection documentWithID: @"word2" error :&error] error: &error];
[wordsCollection deleteDocument: [wordsCollection documentWithID: @"word2" error : &error] error: &error];

rs = [q execute: &error];
allObjects = rs.allObjects;
Expand All @@ -319,7 +323,7 @@ - (void) _testCreateVectorIndexUsingPredictionModelWithInvalidVectors {

CBLDatabase *modelDb = [self openDBNamed: kDatabaseName error: &error];
CBLWordEmbeddingModel* model = [[CBLWordEmbeddingModel alloc] initWithDatabase: modelDb];
[CBLDatabase.prediction registerModel: model withName:@"WordEmbedding"];
[CBLDatabase.prediction registerModel: model withName: @"WordEmbedding"];

// Update docs:
CBLMutableDocument* auxDoc = [[collection documentWithID: @"word1" error: &error] toMutable];
Expand Down Expand Up @@ -367,7 +371,7 @@ - (void) _testCreateVectorIndexUsingPredictionModelWithInvalidVectors {

auxDoc = [[collection documentWithID: @"word5" error: &error] toMutable];
[auxDoc setArray: nil forKey: @"vector"];
Assert([collection saveDocument:auxDoc error:&error]);
Assert([collection saveDocument: auxDoc error: &error]);

// CBL-5453
rs = [q execute: &error];
Expand Down

0 comments on commit a60633d

Please sign in to comment.