@@ -8,19 +8,19 @@ class CustomFunctionNoArgsTests: SQLiteTestCase {
88 typealias FunctionNoOptional = ( ) -> Expression < String >
99 typealias FunctionResultOptional = ( ) -> Expression < String ? >
1010
11- func testFunctionNoOptional( ) {
12- let _: FunctionNoOptional = try ! db. createFunction ( " test " , deterministic: true ) {
11+ func testFunctionNoOptional( ) throws {
12+ let _: FunctionNoOptional = try db. createFunction ( " test " , deterministic: true ) {
1313 " a "
1414 }
15- let result = try ! db. prepare ( " SELECT test() " ) . scalar ( ) as! String
15+ let result = try db. prepare ( " SELECT test() " ) . scalar ( ) as! String
1616 XCTAssertEqual ( " a " , result)
1717 }
1818
19- func testFunctionResultOptional( ) {
20- let _: FunctionResultOptional = try ! db. createFunction ( " test " , deterministic: true ) {
19+ func testFunctionResultOptional( ) throws {
20+ let _: FunctionResultOptional = try db. createFunction ( " test " , deterministic: true ) {
2121 " a "
2222 }
23- let result = try ! db. prepare ( " SELECT test() " ) . scalar ( ) as! String ?
23+ let result = try db. prepare ( " SELECT test() " ) . scalar ( ) as! String ?
2424 XCTAssertEqual ( " a " , result)
2525 }
2626}
@@ -31,35 +31,35 @@ class CustomFunctionWithOneArgTests: SQLiteTestCase {
3131 typealias FunctionResultOptional = ( Expression < String > ) -> Expression < String ? >
3232 typealias FunctionLeftResultOptional = ( Expression < String ? > ) -> Expression < String ? >
3333
34- func testFunctionNoOptional( ) {
35- let _: FunctionNoOptional = try ! db. createFunction ( " test " , deterministic: true ) { a in
34+ func testFunctionNoOptional( ) throws {
35+ let _: FunctionNoOptional = try db. createFunction ( " test " , deterministic: true ) { a in
3636 " b " + a
3737 }
38- let result = try ! db. prepare ( " SELECT test(?) " ) . scalar ( " a " ) as! String
38+ let result = try db. prepare ( " SELECT test(?) " ) . scalar ( " a " ) as! String
3939 XCTAssertEqual ( " ba " , result)
4040 }
4141
42- func testFunctionLeftOptional( ) {
43- let _: FunctionLeftOptional = try ! db. createFunction ( " test " , deterministic: true ) { a in
42+ func testFunctionLeftOptional( ) throws {
43+ let _: FunctionLeftOptional = try db. createFunction ( " test " , deterministic: true ) { a in
4444 " b " + a!
4545 }
46- let result = try ! db. prepare ( " SELECT test(?) " ) . scalar ( " a " ) as! String
46+ let result = try db. prepare ( " SELECT test(?) " ) . scalar ( " a " ) as! String
4747 XCTAssertEqual ( " ba " , result)
4848 }
4949
50- func testFunctionResultOptional( ) {
51- let _: FunctionResultOptional = try ! db. createFunction ( " test " , deterministic: true ) { a in
50+ func testFunctionResultOptional( ) throws {
51+ let _: FunctionResultOptional = try db. createFunction ( " test " , deterministic: true ) { a in
5252 " b " + a
5353 }
54- let result = try ! db. prepare ( " SELECT test(?) " ) . scalar ( " a " ) as! String
54+ let result = try db. prepare ( " SELECT test(?) " ) . scalar ( " a " ) as! String
5555 XCTAssertEqual ( " ba " , result)
5656 }
5757
58- func testFunctionLeftResultOptional( ) {
59- let _: FunctionLeftResultOptional = try ! db. createFunction ( " test " , deterministic: true ) { ( a: String ? ) -> String ? in
58+ func testFunctionLeftResultOptional( ) throws {
59+ let _: FunctionLeftResultOptional = try db. createFunction ( " test " , deterministic: true ) { ( a: String ? ) -> String ? in
6060 " b " + a!
6161 }
62- let result = try ! db. prepare ( " SELECT test(?) " ) . scalar ( " a " ) as! String
62+ let result = try db. prepare ( " SELECT test(?) " ) . scalar ( " a " ) as! String
6363 XCTAssertEqual ( " ba " , result)
6464 }
6565}
@@ -74,76 +74,76 @@ class CustomFunctionWithTwoArgsTests: SQLiteTestCase {
7474 typealias FunctionRightResultOptional = ( Expression < String > , Expression < String ? > ) -> Expression < String ? >
7575 typealias FunctionLeftRightResultOptional = ( Expression < String ? > , Expression < String ? > ) -> Expression < String ? >
7676
77- func testNoOptional( ) {
78- let _: FunctionNoOptional = try ! db. createFunction ( " test " , deterministic: true ) { a, b in
77+ func testNoOptional( ) throws {
78+ let _: FunctionNoOptional = try db. createFunction ( " test " , deterministic: true ) { a, b in
7979 a + b
8080 }
81- let result = try ! db. prepare ( " SELECT test(?, ?) " ) . scalar ( " a " , " b " ) as! String
81+ let result = try db. prepare ( " SELECT test(?, ?) " ) . scalar ( " a " , " b " ) as! String
8282 XCTAssertEqual ( " ab " , result)
8383 }
8484
85- func testLeftOptional( ) {
86- let _: FunctionLeftOptional = try ! db. createFunction ( " test " , deterministic: true ) { a, b in
85+ func testLeftOptional( ) throws {
86+ let _: FunctionLeftOptional = try db. createFunction ( " test " , deterministic: true ) { a, b in
8787 a! + b
8888 }
89- let result = try ! db. prepare ( " SELECT test(?, ?) " ) . scalar ( " a " , " b " ) as! String
89+ let result = try db. prepare ( " SELECT test(?, ?) " ) . scalar ( " a " , " b " ) as! String
9090 XCTAssertEqual ( " ab " , result)
9191 }
9292
93- func testRightOptional( ) {
94- let _: FunctionRightOptional = try ! db. createFunction ( " test " , deterministic: true ) { a, b in
93+ func testRightOptional( ) throws {
94+ let _: FunctionRightOptional = try db. createFunction ( " test " , deterministic: true ) { a, b in
9595 a + b!
9696 }
97- let result = try ! db. prepare ( " SELECT test(?, ?) " ) . scalar ( " a " , " b " ) as! String
97+ let result = try db. prepare ( " SELECT test(?, ?) " ) . scalar ( " a " , " b " ) as! String
9898 XCTAssertEqual ( " ab " , result)
9999 }
100100
101- func testResultOptional( ) {
102- let _: FunctionResultOptional = try ! db. createFunction ( " test " , deterministic: true ) { a, b in
101+ func testResultOptional( ) throws {
102+ let _: FunctionResultOptional = try db. createFunction ( " test " , deterministic: true ) { a, b in
103103 a + b
104104 }
105- let result = try ! db. prepare ( " SELECT test(?, ?) " ) . scalar ( " a " , " b " ) as! String ?
105+ let result = try db. prepare ( " SELECT test(?, ?) " ) . scalar ( " a " , " b " ) as! String ?
106106 XCTAssertEqual ( " ab " , result)
107107 }
108108
109- func testFunctionLeftRightOptional( ) {
110- let _: FunctionLeftRightOptional = try ! db. createFunction ( " test " , deterministic: true ) { a, b in
109+ func testFunctionLeftRightOptional( ) throws {
110+ let _: FunctionLeftRightOptional = try db. createFunction ( " test " , deterministic: true ) { a, b in
111111 a! + b!
112112 }
113- let result = try ! db. prepare ( " SELECT test(?, ?) " ) . scalar ( " a " , " b " ) as! String
113+ let result = try db. prepare ( " SELECT test(?, ?) " ) . scalar ( " a " , " b " ) as! String
114114 XCTAssertEqual ( " ab " , result)
115115 }
116116
117- func testFunctionLeftResultOptional( ) {
118- let _: FunctionLeftResultOptional = try ! db. createFunction ( " test " , deterministic: true ) { a, b in
117+ func testFunctionLeftResultOptional( ) throws {
118+ let _: FunctionLeftResultOptional = try db. createFunction ( " test " , deterministic: true ) { a, b in
119119 a! + b
120120 }
121- let result = try ! db. prepare ( " SELECT test(?, ?) " ) . scalar ( " a " , " b " ) as! String ?
121+ let result = try db. prepare ( " SELECT test(?, ?) " ) . scalar ( " a " , " b " ) as! String ?
122122 XCTAssertEqual ( " ab " , result)
123123 }
124124
125- func testFunctionRightResultOptional( ) {
126- let _: FunctionRightResultOptional = try ! db. createFunction ( " test " , deterministic: true ) { a, b in
125+ func testFunctionRightResultOptional( ) throws {
126+ let _: FunctionRightResultOptional = try db. createFunction ( " test " , deterministic: true ) { a, b in
127127 a + b!
128128 }
129- let result = try ! db. prepare ( " SELECT test(?, ?) " ) . scalar ( " a " , " b " ) as! String ?
129+ let result = try db. prepare ( " SELECT test(?, ?) " ) . scalar ( " a " , " b " ) as! String ?
130130 XCTAssertEqual ( " ab " , result)
131131 }
132132
133- func testFunctionLeftRightResultOptional( ) {
134- let _: FunctionLeftRightResultOptional = try ! db. createFunction ( " test " , deterministic: true ) { a, b in
133+ func testFunctionLeftRightResultOptional( ) throws {
134+ let _: FunctionLeftRightResultOptional = try db. createFunction ( " test " , deterministic: true ) { a, b in
135135 a! + b!
136136 }
137- let result = try ! db. prepare ( " SELECT test(?, ?) " ) . scalar ( " a " , " b " ) as! String ?
137+ let result = try db. prepare ( " SELECT test(?, ?) " ) . scalar ( " a " , " b " ) as! String ?
138138 XCTAssertEqual ( " ab " , result)
139139 }
140140}
141141
142142class CustomFunctionTruncation : SQLiteTestCase {
143143 // https://github.com/stephencelis/SQLite.swift/issues/468
144- func testStringTruncation( ) {
145- _ = try ! db. createFunction ( " customLower " ) { ( value: String ) in value. lowercased ( ) }
146- let result = try ! db. prepare ( " SELECT customLower(?) " ) . scalar ( " TÖL-AA 12 " ) as? String
144+ func testStringTruncation( ) throws {
145+ _ = try db. createFunction ( " customLower " ) { ( value: String ) in value. lowercased ( ) }
146+ let result = try db. prepare ( " SELECT customLower(?) " ) . scalar ( " TÖL-AA 12 " ) as? String
147147 XCTAssertEqual ( " töl-aa 12 " , result)
148148 }
149149}
0 commit comments