From bb3b7059a324651e89357da0e6edeaa2c5d06d36 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Wed, 16 Nov 2016 15:09:42 +0000 Subject: [PATCH] public check method, needed for #389 --- SQLite/Core/Connection.swift | 2 +- SQLiteTests/ConnectionTests.swift | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/SQLite/Core/Connection.swift b/SQLite/Core/Connection.swift index e96a84b5..6b447305 100644 --- a/SQLite/Core/Connection.swift +++ b/SQLite/Core/Connection.swift @@ -674,7 +674,7 @@ public final class Connection { return success! } - @discardableResult func check(_ resultCode: Int32, statement: Statement? = nil) throws -> Int32 { + @discardableResult public func check(_ resultCode: Int32, statement: Statement? = nil) throws -> Int32 { guard let error = Result(errorCode: resultCode, connection: self, statement: statement) else { return resultCode } diff --git a/SQLiteTests/ConnectionTests.swift b/SQLiteTests/ConnectionTests.swift index 20d4215a..6455d30a 100644 --- a/SQLiteTests/ConnectionTests.swift +++ b/SQLiteTests/ConnectionTests.swift @@ -338,4 +338,11 @@ class ConnectionTests : SQLiteTestCase { AssertThrows(try stmt.run()) } + func test_check_with_successCode_returnsCode() { + try! XCTAssertEqual(SQLITE_OK, db.check(SQLITE_OK)) + } + + func test_check_with_errorCode_throws() { + XCTAssertThrowsError(try db.check(SQLITE_CONSTRAINT)) + } }