mirror of
https://github.com/darlinghq/fmdb.git
synced 2025-02-20 13:53:44 +00:00
Merge branch 'module_name' of git://github.com/stephanheilner/fmdb into stephanheilner-module_name
This commit is contained in:
commit
48c333a82f
@ -1,11 +1,11 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'FMDB'
|
||||
s.version = '2.4.1'
|
||||
s.version = '2.5'
|
||||
s.summary = 'A Cocoa / Objective-C wrapper around SQLite.'
|
||||
s.homepage = 'https://github.com/ccgus/fmdb'
|
||||
s.license = 'MIT'
|
||||
s.author = { 'August Mueller' => 'gus@flyingmeat.com' }
|
||||
s.source = { :git => 'https://github.com/ccgus/fmdb.git', :tag => 'v2.4.1' }
|
||||
s.source = { :git => 'https://github.com/ccgus/fmdb.git', :tag => 'v2.5' }
|
||||
s.requires_arc = true
|
||||
|
||||
s.default_subspec = 'standard'
|
||||
|
@ -27,7 +27,7 @@ static id<FMTokenizerDelegate> g_testTok = nil;
|
||||
|
||||
// Create a tokenizer instance that will not be de-allocated when the method finishes.
|
||||
g_testTok = [[FMSimpleTokenizer alloc] initWithLocale:NULL];
|
||||
[FMDatabase registerTokenizer:g_testTok withName:@"testTok"];
|
||||
[FMDatabase registerTokenizer:g_testTok withKey:@"testTok"];
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
|
83
Tests/FMDatabaseFTS3WithModuleNameTests.m
Normal file
83
Tests/FMDatabaseFTS3WithModuleNameTests.m
Normal file
@ -0,0 +1,83 @@
|
||||
//
|
||||
// FMDatabaseFTS3WithKeyTests.m
|
||||
// fmdb
|
||||
//
|
||||
// Created by Stephan Heilner on 1/21/15.
|
||||
//
|
||||
//
|
||||
|
||||
#import "FMDBTempDBTests.h"
|
||||
#import "FMDatabase+FTS3.h"
|
||||
#import "FMTokenizers.h"
|
||||
|
||||
@interface FMDatabaseFTS3WithModuleNameTests : FMDBTempDBTests
|
||||
|
||||
@end
|
||||
|
||||
static id<FMTokenizerDelegate> g_testTok = nil;
|
||||
|
||||
@implementation FMDatabaseFTS3WithModuleNameTests
|
||||
|
||||
+ (void)populateDatabase:(FMDatabase *)db
|
||||
{
|
||||
[db executeUpdate:@"CREATE VIRTUAL TABLE mail USING fts3(subject, body)"];
|
||||
|
||||
[db executeUpdate:@"INSERT INTO mail VALUES('hello world', 'This message is a hello world message.')"];
|
||||
[db executeUpdate:@"INSERT INTO mail VALUES('urgent: serious', 'This mail is seen as a more serious mail')"];
|
||||
|
||||
// Create a tokenizer instance that will not be de-allocated when the method finishes.
|
||||
g_testTok = [[FMSimpleTokenizer alloc] initWithLocale:NULL];
|
||||
[FMDatabase registerTokenizer:g_testTok];
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
[super setUp];
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
{
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
- (void)testOffsets
|
||||
{
|
||||
FMResultSet *results = [self.db executeQuery:@"SELECT offsets(mail) FROM mail WHERE mail MATCH 'world'"];
|
||||
|
||||
if ([results next]) {
|
||||
FMTextOffsets *offsets = [results offsetsForColumnIndex:0];
|
||||
|
||||
[offsets enumerateWithBlock:^(NSInteger columnNumber, NSInteger termNumber, NSRange matchRange) {
|
||||
if (columnNumber == 0) {
|
||||
XCTAssertEqual(termNumber, 0L);
|
||||
XCTAssertEqual(matchRange.location, 6UL);
|
||||
XCTAssertEqual(matchRange.length, 5UL);
|
||||
} else if (columnNumber == 1) {
|
||||
XCTAssertEqual(termNumber, 0L);
|
||||
XCTAssertEqual(matchRange.location, 24UL);
|
||||
XCTAssertEqual(matchRange.length, 5UL);
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testTokenizer
|
||||
{
|
||||
[self.db installTokenizerModuleWithName:@"TestModuleName"];
|
||||
|
||||
BOOL ok = [self.db executeUpdate:@"CREATE VIRTUAL TABLE simple_fts USING fts3(tokenize=TestModuleName)"];
|
||||
XCTAssertTrue(ok, @"Failed to create virtual table: %@", [self.db lastErrorMessage]);
|
||||
|
||||
// The FMSimpleTokenizer handles non-ASCII characters well, since it's based on CFStringTokenizer.
|
||||
NSString *text = @"I like the band Queensrÿche. They are really great.";
|
||||
|
||||
ok = [self.db executeUpdate:@"INSERT INTO simple_fts VALUES(?)", text];
|
||||
XCTAssertTrue(ok, @"Failed to insert data: %@", [self.db lastErrorMessage]);
|
||||
|
||||
FMResultSet *results = [self.db executeQuery:@"SELECT * FROM simple_fts WHERE simple_fts MATCH ?", @"Queensrÿche"];
|
||||
XCTAssertTrue([results next], @"Failed to find result");
|
||||
}
|
||||
|
||||
@end
|
@ -45,6 +45,7 @@
|
||||
CCC24EC20A13E34D00A6D3E3 /* FMDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = CCC24EBB0A13E34D00A6D3E3 /* FMDatabase.m */; };
|
||||
CCC24EC50A13E34D00A6D3E3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = CCC24EBE0A13E34D00A6D3E3 /* main.m */; };
|
||||
CCC24EC70A13E34D00A6D3E3 /* FMResultSet.m in Sources */ = {isa = PBXBuildFile; fileRef = CCC24EC00A13E34D00A6D3E3 /* FMResultSet.m */; };
|
||||
D4A740A21A7046330058EBEE /* FMDatabaseFTS3WithModuleNameTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D4A740A11A7046330058EBEE /* FMDatabaseFTS3WithModuleNameTests.m */; };
|
||||
EE42910512B42FBC0088BD94 /* FMDatabaseAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CC50F2CB0DF9183600E4AAAE /* FMDatabaseAdditions.m */; };
|
||||
EE42910612B42FC30088BD94 /* FMDatabaseAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = CC50F2CC0DF9183600E4AAAE /* FMDatabaseAdditions.h */; };
|
||||
EE42910712B42FC90088BD94 /* FMDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC24EBA0A13E34D00A6D3E3 /* FMDatabase.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@ -133,6 +134,7 @@
|
||||
CCC24EBE0A13E34D00A6D3E3 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = src/sample/main.m; sourceTree = SOURCE_ROOT; };
|
||||
CCC24EBF0A13E34D00A6D3E3 /* FMResultSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FMResultSet.h; path = src/fmdb/FMResultSet.h; sourceTree = SOURCE_ROOT; };
|
||||
CCC24EC00A13E34D00A6D3E3 /* FMResultSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FMResultSet.m; path = src/fmdb/FMResultSet.m; sourceTree = SOURCE_ROOT; };
|
||||
D4A740A11A7046330058EBEE /* FMDatabaseFTS3WithModuleNameTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabaseFTS3WithModuleNameTests.m; sourceTree = "<group>"; };
|
||||
EE4290EF12B42F870088BD94 /* libFMDB.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libFMDB.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
EE42910C12B42FFA0088BD94 /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; };
|
||||
/* End PBXFileReference section */
|
||||
@ -297,6 +299,7 @@
|
||||
children = (
|
||||
BF940F5D18417DEA0001E077 /* FMDatabaseAdditionsTests.m */,
|
||||
67CB1E2F19AD27D000A3CA7F /* FMDatabaseFTS3Tests.m */,
|
||||
D4A740A11A7046330058EBEE /* FMDatabaseFTS3WithModuleNameTests.m */,
|
||||
BFE55E121841C9A000CB3A63 /* FMDatabasePoolTests.m */,
|
||||
BFE55E141841D38800CB3A63 /* FMDatabaseQueueTests.m */,
|
||||
BF5D042018416BB2008C5AA9 /* FMDatabaseTests.m */,
|
||||
@ -514,6 +517,7 @@
|
||||
67CB1E3019AD27D000A3CA7F /* FMDatabaseFTS3Tests.m in Sources */,
|
||||
BFE55E131841C9A000CB3A63 /* FMDatabasePoolTests.m in Sources */,
|
||||
BFE55E151841D38800CB3A63 /* FMDatabaseQueueTests.m in Sources */,
|
||||
D4A740A21A7046330058EBEE /* FMDatabaseFTS3WithModuleNameTests.m in Sources */,
|
||||
CCA66A2E19C0CB1900EFDAC1 /* FMDatabase+FTS3.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user