Add two safety tests for parenthesis

This commit is contained in:
Gwendal Roué committed 2019-05-28 08:03:33 +02:00
1 parent 4729405625
commit b0e140d4bb
2 files changed
+6 -2

No files matched your search

+3 -1
View File
@@ -59,6 +59,7 @@ class SQLInterpolationTests: GRDBTestCase {
let nilInteger: Int? = nil
sql.appendInterpolation(a); sql.appendLiteral("\n")
sql.appendInterpolation(a + 1); sql.appendLiteral("\n")
sql.appendInterpolation(2 * (a + 1)); sql.appendLiteral("\n")
sql.appendInterpolation(a < b); sql.appendLiteral("\n")
sql.appendInterpolation(integer); sql.appendLiteral("\n")
sql.appendInterpolation(optionalInteger); sql.appendLiteral("\n")
@@ -68,13 +69,14 @@ class SQLInterpolationTests: GRDBTestCase {
XCTAssertEqual(sql.sql, """
"a"
"a" + ?
? * ("a" + ?)
"a" < "b"
?
?
NULL
"a" IS NULL
""")
XCTAssertEqual(sql.arguments, [1, 1, 2])
XCTAssertEqual(sql.arguments, [1, 2, 1, 1, 2])
}
func testQualifiedExpressionInterpolation() {
+3 -1
View File
@@ -189,6 +189,7 @@ extension SQLLiteralTests {
SELECT
\(a),
\(a + 1),
\(2 * (a + 1)),
\(a < b),
\(integer),
\(optionalInteger),
@@ -199,13 +200,14 @@ extension SQLLiteralTests {
SELECT
"a",
"a" + ?,
? * ("a" + ?),
"a" < "b",
?,
?,
NULL,
"a" IS NULL
""")
XCTAssertEqual(query.arguments, [1, 1, 2])
XCTAssertEqual(query.arguments, [1, 2, 1, 1, 2])
}
func testQualifiedExpressionInterpolation() {