Files
GRDB.swift/Tests/Public/Foundation/DatabaseCoderTests.swift
T
swiftlyfalling 30bc7e4f6c Replace most uses of #if SQLITE_HAS_CODEC with the appropriate USING_BUILTIN_SQLITE or USING_SQLCIPHER defines.
This enables easier compilation of a custom version of SQLite that
itself uses the SQLITE_HAS_CODEC define. (ex. If building SQLite with
the SQLite Encryption Extension.)
The SQLITE_HAS_CODEC define is now only used to guard use of the SQLite
encryption APIs.
GRDBCipher builds define USING_BUILTIN_SQLITE and USING_SQLCIPHER.
2016-05-30 18:19:45 -04:00

28 lines
843 B
Swift

import XCTest
#if USING_SQLCIPHER
import GRDBCipher
#elseif USING_CUSTOMSQLITE
import GRDBCustomSQLite
#else
import GRDB
#endif
class DatabaseCoderTests: GRDBTestCase {
func testDatabaseCoder() {
assertNoError {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
try db.execute("CREATE TABLE arrays (array BLOB)")
let array = [1,2,3]
try db.execute("INSERT INTO arrays VALUES (?)", arguments: [DatabaseCoder(array)])
let row = Row.fetchOne(db, "SELECT * FROM arrays")!
let fetchedArray = ((row.value(named: "array") as DatabaseCoder).object as! NSArray).map { $0 as! Int }
XCTAssertEqual(array, fetchedArray)
}
}
}
}