Files
GRDB.swift/Tests/Crash/StatementColumnConvertibleCrashTests.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

65 lines
2.3 KiB
Swift

import XCTest
#if USING_SQLCIPHER
import GRDBCipher
#elseif USING_CUSTOMSQLITE
import GRDBCustomSQLite
#else
import GRDB
#endif
class StatementColumnConvertibleCrashTests: GRDBCrashTestCase {
func testCrashFetchStatementColumnConvertibleFromStatement() {
assertCrash("could not convert NULL to Int.") {
try dbQueue.inDatabase { db in
try db.execute("CREATE TABLE ints (int Int)")
try db.execute("INSERT INTO ints (int) VALUES (1)")
try db.execute("INSERT INTO ints (int) VALUES (NULL)")
let statement = try db.selectStatement("SELECT int FROM ints ORDER BY int")
let sequence = Int.fetch(statement)
for _ in sequence { }
}
}
}
func testCrashFetchAllStatementColumnConvertibleFromStatement() {
assertCrash("could not convert NULL to Int.") {
try dbQueue.inDatabase { db in
try db.execute("CREATE TABLE ints (int Int)")
try db.execute("INSERT INTO ints (int) VALUES (1)")
try db.execute("INSERT INTO ints (int) VALUES (NULL)")
let statement = try db.selectStatement("SELECT int FROM ints ORDER BY int")
_ = Int.fetchAll(statement)
}
}
}
func testCrashFetchStatementColumnConvertibleFromDatabase() {
assertCrash("could not convert NULL to Int.") {
try dbQueue.inDatabase { db in
try db.execute("CREATE TABLE ints (int Int)")
try db.execute("INSERT INTO ints (int) VALUES (1)")
try db.execute("INSERT INTO ints (int) VALUES (NULL)")
let sequence = Int.fetch(db, "SELECT int FROM ints ORDER BY int")
for _ in sequence { }
}
}
}
func testCrashFetchAllStatementColumnConvertibleFromDatabase() {
assertCrash("could not convert NULL to Int.") {
try dbQueue.inDatabase { db in
try db.execute("CREATE TABLE ints (int Int)")
try db.execute("INSERT INTO ints (int) VALUES (1)")
try db.execute("INSERT INTO ints (int) VALUES (NULL)")
_ = Int.fetchAll(db, "SELECT int FROM ints ORDER BY int")
}
}
}
}