Skip to content

Commit

Permalink
fixed Linux testing
Browse files Browse the repository at this point in the history
  • Loading branch information
adriencanterot committed Sep 29, 2016
1 parent 60f4d72 commit fbc30d8
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions Tests/SQLiteTests/SQLite3Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@ import XCTest
@testable import SQLite

class SQLite3Tests: XCTestCase {
static let allTests = ["testTables": testTables,
"testUnicode": testUnicode]
static let allTests = [("testTables", testTables),
("testUnicode", testUnicode)]

var database:SQLite!

override func setUp() {
self.database = SQLite.makeTestConnection()
}

func testTables() {
do {
try _ = database.execute("DROP TABLE IF EXISTS foo")
try _ = database.execute("CREATE TABLE foo (bar INT(4), baz VARCHAR(16))")
try _ = database.execute("INSERT INTO foo VALUES (42, 'Life')")
try _ = database.execute("INSERT INTO foo VALUES (1337, 'Elite')")
try _ = database.execute("INSERT INTO foo VALUES (9, NULL)")

if let resultBar = try database.execute("SELECT * FROM foo WHERE bar = 42").first {
XCTAssertEqual(resultBar.data["bar"], "42")
XCTAssertEqual(resultBar.data["baz"], "Life")
} else {
XCTFail("Could not get bar result")
}


if let resultBaz = try database.execute("SELECT * FROM foo where baz = 'Elite'").first {
XCTAssertEqual(resultBaz.data["bar"], "1337")
XCTAssertEqual(resultBaz.data["baz"], "Elite")
} else {
XCTFail("Could not get baz result")
}

if let resultBaz = try database.execute("SELECT * FROM foo where bar = 9").first {
XCTAssertEqual(resultBaz.data["bar"], "9")
XCTAssertEqual(resultBaz.data["baz"], nil)
Expand All @@ -44,13 +44,13 @@ class SQLite3Tests: XCTestCase {
XCTFail("Testing tables failed: \(error)")
}
}

func testUnicode() {

do {

/**
This string includes characters from most Unicode categories
This string includes characters from most Unicode categories
such as Latin, Latin-Extended-A/B, Cyrrilic, Greek etc.
*/
let unicode = "®¿ÐØ×ĞƋƢǂNJǕǮȐȘȢȱȵẀˍΔῴЖ♆"
Expand All @@ -59,7 +59,7 @@ class SQLite3Tests: XCTestCase {
try _ = database.execute("INSERT INTO `foo` VALUES(?)") { statement in
try statement.bind(unicode)
}

if let results = try database.execute("SELECT * FROM `foo`").first {
XCTAssertEqual(results.data["bar"], unicode)
}
Expand All @@ -68,5 +68,5 @@ class SQLite3Tests: XCTestCase {
}

}

}

0 comments on commit fbc30d8

Please sign in to comment.