mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
Remove performance database resources
This commit is contained in:
1 parent
354b815835
commit
795daf284f
10 files changed
+132
-53
No files matched your search
@@ -10,8 +10,9 @@ private let expectedRowCount = 100_000
|
||||
class FetchNamedValuesTests: XCTestCase {
|
||||
|
||||
func testGRDB() throws {
|
||||
let databasePath = Bundle(for: type(of: self)).path(forResource: "PerformanceTests", ofType: "sqlite")!
|
||||
let dbQueue = try DatabaseQueue(path: databasePath)
|
||||
let url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("GRDBPerformanceTests.sqlite")
|
||||
try generateSQLiteDatabaseIfMissing(at: url, insertedRowCount: expectedRowCount)
|
||||
let dbQueue = try DatabaseQueue(path: url.path)
|
||||
|
||||
measure {
|
||||
var count = 0
|
||||
@@ -39,9 +40,10 @@ class FetchNamedValuesTests: XCTestCase {
|
||||
}
|
||||
|
||||
#if GRDB_COMPARE
|
||||
func testFMDB() {
|
||||
let databasePath = Bundle(for: type(of: self)).path(forResource: "PerformanceTests", ofType: "sqlite")!
|
||||
let dbQueue = FMDatabaseQueue(path: databasePath)!
|
||||
func testFMDB() throws {
|
||||
let url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("GRDBPerformanceTests.sqlite")
|
||||
try generateSQLiteDatabaseIfMissing(at: url, insertedRowCount: expectedRowCount)
|
||||
let dbQueue = FMDatabaseQueue(path: url.path)!
|
||||
|
||||
measure {
|
||||
var count = 0
|
||||
@@ -69,8 +71,9 @@ class FetchNamedValuesTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testSQLiteSwift() throws {
|
||||
let databasePath = Bundle(for: type(of: self)).path(forResource: "PerformanceTests", ofType: "sqlite")!
|
||||
let db = try Connection(databasePath)
|
||||
let url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("GRDBPerformanceTests.sqlite")
|
||||
try generateSQLiteDatabaseIfMissing(at: url, insertedRowCount: expectedRowCount)
|
||||
let db = try Connection(url.path)
|
||||
|
||||
measure {
|
||||
var count = 0
|
||||
|
||||
@@ -9,10 +9,11 @@ private let expectedRowCount = 100_000
|
||||
/// Here we test the extraction of values by column index.
|
||||
class FetchPositionalValuesTests: XCTestCase {
|
||||
|
||||
func testSQLite() {
|
||||
let databasePath = Bundle(for: type(of: self)).path(forResource: "PerformanceTests", ofType: "sqlite")!
|
||||
func testSQLite() throws {
|
||||
let url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("GRDBPerformanceTests.sqlite")
|
||||
try generateSQLiteDatabaseIfMissing(at: url, insertedRowCount: expectedRowCount)
|
||||
var connection: OpaquePointer? = nil
|
||||
sqlite3_open_v2(databasePath, &connection, 0x00000004 /*SQLITE_OPEN_CREATE*/ | 0x00000002 /*SQLITE_OPEN_READWRITE*/, nil)
|
||||
sqlite3_open_v2(url.path, &connection, 0x00000004 /*SQLITE_OPEN_CREATE*/ | 0x00000002 /*SQLITE_OPEN_READWRITE*/, nil)
|
||||
|
||||
measure {
|
||||
var count = 0
|
||||
@@ -51,8 +52,9 @@ class FetchPositionalValuesTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testGRDB() throws {
|
||||
let databasePath = Bundle(for: type(of: self)).path(forResource: "PerformanceTests", ofType: "sqlite")!
|
||||
let dbQueue = try DatabaseQueue(path: databasePath)
|
||||
let url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("GRDBPerformanceTests.sqlite")
|
||||
try generateSQLiteDatabaseIfMissing(at: url, insertedRowCount: expectedRowCount)
|
||||
let dbQueue = try DatabaseQueue(path: url.path)
|
||||
|
||||
measure {
|
||||
var count = 0
|
||||
@@ -80,9 +82,10 @@ class FetchPositionalValuesTests: XCTestCase {
|
||||
}
|
||||
|
||||
#if GRDB_COMPARE
|
||||
func testFMDB() {
|
||||
let databasePath = Bundle(for: type(of: self)).path(forResource: "PerformanceTests", ofType: "sqlite")!
|
||||
let dbQueue = FMDatabaseQueue(path: databasePath)!
|
||||
func testFMDB() throws {
|
||||
let url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("GRDBPerformanceTests.sqlite")
|
||||
try generateSQLiteDatabaseIfMissing(at: url, insertedRowCount: expectedRowCount)
|
||||
let dbQueue = FMDatabaseQueue(path: url.path)!
|
||||
|
||||
measure {
|
||||
var count = 0
|
||||
@@ -110,8 +113,9 @@ class FetchPositionalValuesTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testSQLiteSwift() throws {
|
||||
let databasePath = Bundle(for: type(of: self)).path(forResource: "PerformanceTests", ofType: "sqlite")!
|
||||
let db = try Connection(databasePath)
|
||||
let url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("GRDBPerformanceTests.sqlite")
|
||||
try generateSQLiteDatabaseIfMissing(at: url, insertedRowCount: expectedRowCount)
|
||||
let db = try Connection(url.path)
|
||||
|
||||
measure {
|
||||
var count = 0
|
||||
|
||||
@@ -11,8 +11,9 @@ private let expectedRowCount = 100_000
|
||||
class FetchRecordClassTests: XCTestCase {
|
||||
|
||||
func testGRDB() throws {
|
||||
let databasePath = Bundle(for: type(of: self)).path(forResource: "PerformanceTests", ofType: "sqlite")!
|
||||
let dbQueue = try DatabaseQueue(path: databasePath)
|
||||
let url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("GRDBPerformanceTests.sqlite")
|
||||
try generateSQLiteDatabaseIfMissing(at: url, insertedRowCount: expectedRowCount)
|
||||
let dbQueue = try DatabaseQueue(path: url.path)
|
||||
|
||||
measure {
|
||||
let items = try! dbQueue.inDatabase { db in
|
||||
@@ -27,11 +28,12 @@ class FetchRecordClassTests: XCTestCase {
|
||||
|
||||
#if GRDB_COMPARE
|
||||
func testCoreData() throws {
|
||||
let databasePath = Bundle(for: type(of: self)).path(forResource: "PerformanceCoreDataTests", ofType: "sqlite")!
|
||||
let modelURL = Bundle(for: type(of: self)).url(forResource: "PerformanceModel", withExtension: "momd")!
|
||||
let url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("GRDBCoreDataPerformanceTests.sqlite")
|
||||
try generateCoreDataDatabaseIfMissing(at: url, fromModelAt: modelURL, insertedRowCount: expectedRowCount)
|
||||
let mom = NSManagedObjectModel(contentsOf: modelURL)!
|
||||
let psc = NSPersistentStoreCoordinator(managedObjectModel: mom)
|
||||
try psc.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: URL(fileURLWithPath: databasePath), options: nil)
|
||||
try psc.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: url, options: nil)
|
||||
let moc = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
|
||||
moc.persistentStoreCoordinator = psc
|
||||
|
||||
@@ -56,8 +58,9 @@ class FetchRecordClassTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testRealm() throws {
|
||||
let databaseURL = Bundle(for: type(of: self)).url(forResource: "PerformanceRealmTests", withExtension: "realm")!
|
||||
let realm = try Realm(fileURL: databaseURL)
|
||||
let url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("GRDBRealmPerformanceTests.realm")
|
||||
try generateRealmDatabaseIfMissing(at: url, insertedRowCount: expectedRowCount)
|
||||
let realm = try Realm(fileURL: url)
|
||||
|
||||
measure {
|
||||
let items = realm.objects(RealmItem.self)
|
||||
|
||||
@@ -10,8 +10,9 @@ private let expectedRowCount = 100_000
|
||||
class FetchRecordCodableTests: XCTestCase {
|
||||
|
||||
func testGRDB() throws {
|
||||
let databasePath = Bundle(for: type(of: self)).path(forResource: "PerformanceTests", ofType: "sqlite")!
|
||||
let dbQueue = try DatabaseQueue(path: databasePath)
|
||||
let url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("GRDBPerformanceTests.sqlite")
|
||||
try generateSQLiteDatabaseIfMissing(at: url, insertedRowCount: expectedRowCount)
|
||||
let dbQueue = try DatabaseQueue(path: url.path)
|
||||
|
||||
measure {
|
||||
let items = try! dbQueue.inDatabase { db in
|
||||
|
||||
@@ -9,10 +9,11 @@ private let expectedRowCount = 100_000
|
||||
/// Here we test the extraction of models from rows
|
||||
class FetchRecordStructTests: XCTestCase {
|
||||
|
||||
func testSQLite() {
|
||||
let databasePath = Bundle(for: type(of: self)).path(forResource: "PerformanceTests", ofType: "sqlite")!
|
||||
func testSQLite() throws {
|
||||
let url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("GRDBPerformanceTests.sqlite")
|
||||
try generateSQLiteDatabaseIfMissing(at: url, insertedRowCount: expectedRowCount)
|
||||
var connection: OpaquePointer? = nil
|
||||
sqlite3_open_v2(databasePath, &connection, 0x00000004 /*SQLITE_OPEN_CREATE*/ | 0x00000002 /*SQLITE_OPEN_READWRITE*/, nil)
|
||||
sqlite3_open_v2(url.path, &connection, 0x00000004 /*SQLITE_OPEN_CREATE*/ | 0x00000002 /*SQLITE_OPEN_READWRITE*/, nil)
|
||||
|
||||
measure {
|
||||
var statement: OpaquePointer? = nil
|
||||
@@ -66,8 +67,9 @@ class FetchRecordStructTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testGRDB() throws {
|
||||
let databasePath = Bundle(for: type(of: self)).path(forResource: "PerformanceTests", ofType: "sqlite")!
|
||||
let dbQueue = try DatabaseQueue(path: databasePath)
|
||||
let url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("GRDBPerformanceTests.sqlite")
|
||||
try generateSQLiteDatabaseIfMissing(at: url, insertedRowCount: expectedRowCount)
|
||||
let dbQueue = try DatabaseQueue(path: url.path)
|
||||
|
||||
measure {
|
||||
let items = try! dbQueue.inDatabase { db in
|
||||
@@ -81,11 +83,12 @@ class FetchRecordStructTests: XCTestCase {
|
||||
}
|
||||
|
||||
#if GRDB_COMPARE
|
||||
func testFMDB() {
|
||||
func testFMDB() throws {
|
||||
// Here we test the loading of an array of Records.
|
||||
|
||||
let databasePath = Bundle(for: type(of: self)).path(forResource: "PerformanceTests", ofType: "sqlite")!
|
||||
let dbQueue = FMDatabaseQueue(path: databasePath)!
|
||||
let url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("GRDBPerformanceTests.sqlite")
|
||||
try generateSQLiteDatabaseIfMissing(at: url, insertedRowCount: expectedRowCount)
|
||||
let dbQueue = FMDatabaseQueue(path: url.path)!
|
||||
|
||||
measure {
|
||||
var items = [ItemStruct]()
|
||||
@@ -104,8 +107,9 @@ class FetchRecordStructTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testSQLiteSwift() throws {
|
||||
let databasePath = Bundle(for: type(of: self)).path(forResource: "PerformanceTests", ofType: "sqlite")!
|
||||
let db = try Connection(databasePath)
|
||||
let url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("GRDBPerformanceTests.sqlite")
|
||||
try generateSQLiteDatabaseIfMissing(at: url, insertedRowCount: expectedRowCount)
|
||||
let db = try Connection(url.path)
|
||||
|
||||
measure {
|
||||
var items = [ItemStruct]()
|
||||
|
||||
@@ -22,10 +22,8 @@
|
||||
56439B3E1F4CA1DC0066043F /* PerformanceModel.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 56DE7B2D1C42B23B00861EB8 /* PerformanceModel.xcdatamodeld */; };
|
||||
56439B3F1F4CA1DC0066043F /* FetchPositionalValuesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56DE7B291C4130AF00861EB8 /* FetchPositionalValuesTests.swift */; };
|
||||
56439B431F4CA1DC0066043F /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 56DE7B341C42B37E00861EB8 /* CoreData.framework */; };
|
||||
56439B471F4CA1DC0066043F /* PerformanceRealmTests.realm in Resources */ = {isa = PBXBuildFile; fileRef = 563363F81C960711000BE133 /* PerformanceRealmTests.realm */; };
|
||||
56439B481F4CA1DC0066043F /* PerformanceTests.sqlite in Resources */ = {isa = PBXBuildFile; fileRef = 56BB86111BA9886D001F9168 /* PerformanceTests.sqlite */; };
|
||||
56439B491F4CA1DC0066043F /* PerformanceCoreDataTests.sqlite in Resources */ = {isa = PBXBuildFile; fileRef = 56DE7B361C42BBBB00861EB8 /* PerformanceCoreDataTests.sqlite */; };
|
||||
56439B581F4CA5AE0066043F /* PerformanceTests.sqlite in Resources */ = {isa = PBXBuildFile; fileRef = 56BB86111BA9886D001F9168 /* PerformanceTests.sqlite */; };
|
||||
565BC5E82517645D00D2B53E /* Generation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565BC5E72517645D00D2B53E /* Generation.swift */; };
|
||||
565BC5E92517645D00D2B53E /* Generation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565BC5E72517645D00D2B53E /* Generation.swift */; };
|
||||
56707201208A509C006AD95A /* DateParsingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567071FA208A509C006AD95A /* DateParsingTests.swift */; };
|
||||
5679870223A37A6A0076902D /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 567986B923A378CD0076902D /* GRDB.framework */; };
|
||||
5679870523A37A790076902D /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 567986B923A378CD0076902D /* GRDB.framework */; };
|
||||
@@ -131,13 +129,12 @@
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
560C981A1C0E22D300BF8471 /* GRDBOSXPerformanceTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBOSXPerformanceTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
563363F81C960711000BE133 /* PerformanceRealmTests.realm */ = {isa = PBXFileReference; lastKnownFileType = file; path = PerformanceRealmTests.realm; sourceTree = "<group>"; };
|
||||
56439B501F4CA1DC0066043F /* GRDBOSXPerformanceComparisonTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBOSXPerformanceComparisonTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
565BC5E72517645D00D2B53E /* Generation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Generation.swift; sourceTree = "<group>"; };
|
||||
567071FA208A509C006AD95A /* DateParsingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DateParsingTests.swift; sourceTree = "<group>"; };
|
||||
567986AD23A378CD0076902D /* GRDB.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GRDB.xcodeproj; path = ../../../GRDB.xcodeproj; sourceTree = "<group>"; };
|
||||
5690AFD72120589A001530EA /* InsertRecordCodableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InsertRecordCodableTests.swift; sourceTree = "<group>"; };
|
||||
5690AFDA212058CB001530EA /* FetchRecordCodableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchRecordCodableTests.swift; sourceTree = "<group>"; };
|
||||
56BB86111BA9886D001F9168 /* PerformanceTests.sqlite */ = {isa = PBXFileReference; lastKnownFileType = file; path = PerformanceTests.sqlite; sourceTree = "<group>"; };
|
||||
56BB86121BA9886D001F9168 /* InsertRecordClassTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InsertRecordClassTests.swift; sourceTree = "<group>"; };
|
||||
56BB862D1BA98933001F9168 /* GRDBPerformanceComparisonTests-Bridging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GRDBPerformanceComparisonTests-Bridging.h"; sourceTree = "<group>"; };
|
||||
56CA22211BB41565009A04C5 /* PerformanceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PerformanceTests.swift; sourceTree = "<group>"; };
|
||||
@@ -150,7 +147,6 @@
|
||||
56DE7B2B1C41311900861EB8 /* FetchRecordClassTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchRecordClassTests.swift; sourceTree = "<group>"; };
|
||||
56DE7B2E1C42B23B00861EB8 /* PerformanceModel.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = PerformanceModel.xcdatamodel; sourceTree = "<group>"; };
|
||||
56DE7B341C42B37E00861EB8 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
|
||||
56DE7B361C42BBBB00861EB8 /* PerformanceCoreDataTests.sqlite */ = {isa = PBXFileReference; lastKnownFileType = file; path = PerformanceCoreDataTests.sqlite; sourceTree = "<group>"; };
|
||||
DC37740419C8CBB3004FCF85 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@@ -205,16 +201,14 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56BB862D1BA98933001F9168 /* GRDBPerformanceComparisonTests-Bridging.h */,
|
||||
56BB86111BA9886D001F9168 /* PerformanceTests.sqlite */,
|
||||
56DE7B361C42BBBB00861EB8 /* PerformanceCoreDataTests.sqlite */,
|
||||
56DE7B2D1C42B23B00861EB8 /* PerformanceModel.xcdatamodeld */,
|
||||
563363F81C960711000BE133 /* PerformanceRealmTests.realm */,
|
||||
567071FA208A509C006AD95A /* DateParsingTests.swift */,
|
||||
56DE7B271C41302500861EB8 /* FetchNamedValuesTests.swift */,
|
||||
56DE7B291C4130AF00861EB8 /* FetchPositionalValuesTests.swift */,
|
||||
56DE7B2B1C41311900861EB8 /* FetchRecordClassTests.swift */,
|
||||
5690AFDA212058CB001530EA /* FetchRecordCodableTests.swift */,
|
||||
56D3BE701F4EB1900034C6D2 /* FetchRecordStructTests.swift */,
|
||||
565BC5E72517645D00D2B53E /* Generation.swift */,
|
||||
56DE7B251C412FDA00861EB8 /* InsertNamedValuesTests.swift */,
|
||||
56DE7B231C412F7E00861EB8 /* InsertPositionalValuesTests.swift */,
|
||||
56BB86121BA9886D001F9168 /* InsertRecordClassTests.swift */,
|
||||
@@ -409,7 +403,6 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
56439B581F4CA5AE0066043F /* PerformanceTests.sqlite in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -417,9 +410,6 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
56439B471F4CA1DC0066043F /* PerformanceRealmTests.realm in Resources */,
|
||||
56439B481F4CA1DC0066043F /* PerformanceTests.sqlite in Resources */,
|
||||
56439B491F4CA1DC0066043F /* PerformanceCoreDataTests.sqlite in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -431,6 +421,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
56D3BE711F4EB1A00034C6D2 /* FetchRecordStructTests.swift in Sources */,
|
||||
565BC5E82517645D00D2B53E /* Generation.swift in Sources */,
|
||||
560C98231C0E23BB00BF8471 /* InsertRecordClassTests.swift in Sources */,
|
||||
56707201208A509C006AD95A /* DateParsingTests.swift in Sources */,
|
||||
56DE7B2C1C41311900861EB8 /* FetchRecordClassTests.swift in Sources */,
|
||||
@@ -450,6 +441,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
56439B341F4CA1DC0066043F /* InsertRecordClassTests.swift in Sources */,
|
||||
565BC5E92517645D00D2B53E /* Generation.swift in Sources */,
|
||||
56439B361F4CA1DC0066043F /* FetchRecordClassTests.swift in Sources */,
|
||||
56439B381F4CA1DC0066043F /* FetchNamedValuesTests.swift in Sources */,
|
||||
56439B391F4CA1DC0066043F /* InsertPositionalValuesTests.swift in Sources */,
|
||||
@@ -494,7 +486,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
"@loader_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
@@ -516,7 +508,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
"@loader_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
@@ -538,7 +530,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
"@loader_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D GRDB_COMPARE";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -561,7 +553,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
"@loader_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D GRDB_COMPARE";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import XCTest
|
||||
import Foundation
|
||||
import GRDB
|
||||
#if GRDB_COMPARE
|
||||
import CoreData
|
||||
import RealmSwift
|
||||
#endif
|
||||
|
||||
func generateSQLiteDatabaseIfMissing(at url: URL, insertedRowCount: Int) throws {
|
||||
try DatabaseQueue(path: url.path).write { db in
|
||||
if try db.tableExists("items") {
|
||||
let count = try Int.fetchOne(db, sql: "SELECT COUNT(*) FROM items")!
|
||||
if count == insertedRowCount {
|
||||
return
|
||||
} else {
|
||||
try db.execute(sql: "DROP TABLE items")
|
||||
}
|
||||
}
|
||||
try db.execute(sql: "CREATE TABLE items (i0 INT, i1 INT, i2 INT, i3 INT, i4 INT, i5 INT, i6 INT, i7 INT, i8 INT, i9 INT)")
|
||||
|
||||
let statement = try! db.makeUpdateStatement(sql: "INSERT INTO items (i0, i1, i2, i3, i4, i5, i6, i7, i8, i9) VALUES (?,?,?,?,?,?,?,?,?,?)")
|
||||
for i in 0..<insertedRowCount {
|
||||
try statement.execute(arguments: [i, i, i, i, i, i, i, i, i, i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if GRDB_COMPARE
|
||||
func generateCoreDataDatabaseIfMissing(at url: URL, fromModelAt modelURL: URL, insertedRowCount: Int) throws {
|
||||
let mom = NSManagedObjectModel(contentsOf: modelURL)!
|
||||
let psc = NSPersistentStoreCoordinator(managedObjectModel: mom)
|
||||
let store = try psc.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: url, options: nil)
|
||||
let moc = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
|
||||
moc.performAndWait {
|
||||
moc.persistentStoreCoordinator = psc
|
||||
let request = NSFetchRequest<NSFetchRequestResult>(entityName: "Item")
|
||||
if try! moc.count(for: request) == insertedRowCount {
|
||||
return
|
||||
}
|
||||
try! moc.execute(NSBatchDeleteRequest(fetchRequest: request))
|
||||
|
||||
for i in 0..<insertedRowCount {
|
||||
let item = NSEntityDescription.insertNewObject(forEntityName: "Item", into: moc)
|
||||
item.setValue(NSNumber(value: i), forKey: "i0")
|
||||
item.setValue(NSNumber(value: i), forKey: "i1")
|
||||
item.setValue(NSNumber(value: i), forKey: "i2")
|
||||
item.setValue(NSNumber(value: i), forKey: "i3")
|
||||
item.setValue(NSNumber(value: i), forKey: "i4")
|
||||
item.setValue(NSNumber(value: i), forKey: "i5")
|
||||
item.setValue(NSNumber(value: i), forKey: "i6")
|
||||
item.setValue(NSNumber(value: i), forKey: "i7")
|
||||
item.setValue(NSNumber(value: i), forKey: "i8")
|
||||
item.setValue(NSNumber(value: i), forKey: "i9")
|
||||
}
|
||||
try! moc.save()
|
||||
}
|
||||
}
|
||||
|
||||
func generateRealmDatabaseIfMissing(at url: URL, insertedRowCount: Int) throws {
|
||||
let realm = try Realm(fileURL: url)
|
||||
try realm.write {
|
||||
if realm.objects(RealmItem.self).count == insertedRowCount {
|
||||
return
|
||||
}
|
||||
|
||||
realm.deleteAll()
|
||||
for i in 0..<insertedRowCount {
|
||||
realm.add(RealmItem(i0: i, i1: i, i2: i, i3: i, i4: i, i5: i, i6: i, i7: i, i8: i, i9: i))
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user