Skip to content

Commit 4a92263

Browse files
committed
Test throwing column row accessors
1 parent f72d0ce commit 4a92263

File tree

6 files changed

+142
-104
lines changed

6 files changed

+142
-104
lines changed

Tests/GRDBTests/RowAdapterTests.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ class AdapterRowTests : RowTestCase {
4242
assertRowRawValueEqual(row, index: 2, value: 2 as Int64)
4343

4444
// DatabaseValueConvertible & StatementColumnConvertible
45-
assertRowConvertedValueEqual(row, index: 0, value: 0 as Int)
46-
assertRowConvertedValueEqual(row, index: 1, value: 1 as Int)
47-
assertRowConvertedValueEqual(row, index: 2, value: 2 as Int)
45+
try assertRowConvertedValueEqual(row, index: 0, value: 0 as Int)
46+
try assertRowConvertedValueEqual(row, index: 1, value: 1 as Int)
47+
try assertRowConvertedValueEqual(row, index: 2, value: 2 as Int)
4848

4949
// DatabaseValueConvertible
50-
assertRowConvertedValueEqual(row, index: 0, value: CustomValue.a)
51-
assertRowConvertedValueEqual(row, index: 1, value: CustomValue.b)
52-
assertRowConvertedValueEqual(row, index: 2, value: CustomValue.c)
50+
try assertRowConvertedValueEqual(row, index: 0, value: CustomValue.a)
51+
try assertRowConvertedValueEqual(row, index: 1, value: CustomValue.b)
52+
try assertRowConvertedValueEqual(row, index: 2, value: CustomValue.c)
5353

5454
// Expect fatal error:
5555
//
@@ -70,14 +70,14 @@ class AdapterRowTests : RowTestCase {
7070
assertRowRawValueEqual(row, name: "c", value: 2 as Int64)
7171

7272
// DatabaseValueConvertible & StatementColumnConvertible
73-
assertRowConvertedValueEqual(row, name: "a", value: 0 as Int)
74-
assertRowConvertedValueEqual(row, name: "b", value: 1 as Int)
75-
assertRowConvertedValueEqual(row, name: "c", value: 2 as Int)
73+
try assertRowConvertedValueEqual(row, name: "a", value: 0 as Int)
74+
try assertRowConvertedValueEqual(row, name: "b", value: 1 as Int)
75+
try assertRowConvertedValueEqual(row, name: "c", value: 2 as Int)
7676

7777
// DatabaseValueConvertible
78-
assertRowConvertedValueEqual(row, name: "a", value: CustomValue.a)
79-
assertRowConvertedValueEqual(row, name: "b", value: CustomValue.b)
80-
assertRowConvertedValueEqual(row, name: "c", value: CustomValue.c)
78+
try assertRowConvertedValueEqual(row, name: "a", value: CustomValue.a)
79+
try assertRowConvertedValueEqual(row, name: "b", value: CustomValue.b)
80+
try assertRowConvertedValueEqual(row, name: "c", value: CustomValue.c)
8181
}
8282
}
8383

@@ -93,14 +93,14 @@ class AdapterRowTests : RowTestCase {
9393
assertRowRawValueEqual(row, column: Column("c"), value: 2 as Int64)
9494

9595
// DatabaseValueConvertible & StatementColumnConvertible
96-
assertRowConvertedValueEqual(row, column: Column("a"), value: 0 as Int)
97-
assertRowConvertedValueEqual(row, column: Column("b"), value: 1 as Int)
98-
assertRowConvertedValueEqual(row, column: Column("c"), value: 2 as Int)
96+
try assertRowConvertedValueEqual(row, column: Column("a"), value: 0 as Int)
97+
try assertRowConvertedValueEqual(row, column: Column("b"), value: 1 as Int)
98+
try assertRowConvertedValueEqual(row, column: Column("c"), value: 2 as Int)
9999

100100
// DatabaseValueConvertible
101-
assertRowConvertedValueEqual(row, column: Column("a"), value: CustomValue.a)
102-
assertRowConvertedValueEqual(row, column: Column("b"), value: CustomValue.b)
103-
assertRowConvertedValueEqual(row, column: Column("c"), value: CustomValue.c)
101+
try assertRowConvertedValueEqual(row, column: Column("a"), value: CustomValue.a)
102+
try assertRowConvertedValueEqual(row, column: Column("b"), value: CustomValue.b)
103+
try assertRowConvertedValueEqual(row, column: Column("c"), value: CustomValue.c)
104104
}
105105
}
106106

Tests/GRDBTests/RowCopiedFromStatementTests.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ class RowCopiedFromStatementTests: RowTestCase {
4444
assertRowRawValueEqual(row, index: 2, value: 2 as Int64)
4545

4646
// DatabaseValueConvertible & StatementColumnConvertible
47-
assertRowConvertedValueEqual(row, index: 0, value: 0 as Int)
48-
assertRowConvertedValueEqual(row, index: 1, value: 1 as Int)
49-
assertRowConvertedValueEqual(row, index: 2, value: 2 as Int)
47+
try assertRowConvertedValueEqual(row, index: 0, value: 0 as Int)
48+
try assertRowConvertedValueEqual(row, index: 1, value: 1 as Int)
49+
try assertRowConvertedValueEqual(row, index: 2, value: 2 as Int)
5050

5151
// DatabaseValueConvertible
52-
assertRowConvertedValueEqual(row, index: 0, value: CustomValue.a)
53-
assertRowConvertedValueEqual(row, index: 1, value: CustomValue.b)
54-
assertRowConvertedValueEqual(row, index: 2, value: CustomValue.c)
52+
try assertRowConvertedValueEqual(row, index: 0, value: CustomValue.a)
53+
try assertRowConvertedValueEqual(row, index: 1, value: CustomValue.b)
54+
try assertRowConvertedValueEqual(row, index: 2, value: CustomValue.c)
5555

5656
// Expect fatal error:
5757
//
@@ -73,14 +73,14 @@ class RowCopiedFromStatementTests: RowTestCase {
7373
assertRowRawValueEqual(row, name: "c", value: 2 as Int64)
7474

7575
// DatabaseValueConvertible & StatementColumnConvertible
76-
assertRowConvertedValueEqual(row, name: "a", value: 0 as Int)
77-
assertRowConvertedValueEqual(row, name: "b", value: 1 as Int)
78-
assertRowConvertedValueEqual(row, name: "c", value: 2 as Int)
76+
try assertRowConvertedValueEqual(row, name: "a", value: 0 as Int)
77+
try assertRowConvertedValueEqual(row, name: "b", value: 1 as Int)
78+
try assertRowConvertedValueEqual(row, name: "c", value: 2 as Int)
7979

8080
// DatabaseValueConvertible
81-
assertRowConvertedValueEqual(row, name: "a", value: CustomValue.a)
82-
assertRowConvertedValueEqual(row, name: "b", value: CustomValue.b)
83-
assertRowConvertedValueEqual(row, name: "c", value: CustomValue.c)
81+
try assertRowConvertedValueEqual(row, name: "a", value: CustomValue.a)
82+
try assertRowConvertedValueEqual(row, name: "b", value: CustomValue.b)
83+
try assertRowConvertedValueEqual(row, name: "c", value: CustomValue.c)
8484
}
8585
}
8686

@@ -97,14 +97,14 @@ class RowCopiedFromStatementTests: RowTestCase {
9797
assertRowRawValueEqual(row, column: Column("c"), value: 2 as Int64)
9898

9999
// DatabaseValueConvertible & StatementColumnConvertible
100-
assertRowConvertedValueEqual(row, column: Column("a"), value: 0 as Int)
101-
assertRowConvertedValueEqual(row, column: Column("b"), value: 1 as Int)
102-
assertRowConvertedValueEqual(row, column: Column("c"), value: 2 as Int)
100+
try assertRowConvertedValueEqual(row, column: Column("a"), value: 0 as Int)
101+
try assertRowConvertedValueEqual(row, column: Column("b"), value: 1 as Int)
102+
try assertRowConvertedValueEqual(row, column: Column("c"), value: 2 as Int)
103103

104104
// DatabaseValueConvertible
105-
assertRowConvertedValueEqual(row, column: Column("a"), value: CustomValue.a)
106-
assertRowConvertedValueEqual(row, column: Column("b"), value: CustomValue.b)
107-
assertRowConvertedValueEqual(row, column: Column("c"), value: CustomValue.c)
105+
try assertRowConvertedValueEqual(row, column: Column("a"), value: CustomValue.a)
106+
try assertRowConvertedValueEqual(row, column: Column("b"), value: CustomValue.b)
107+
try assertRowConvertedValueEqual(row, column: Column("c"), value: CustomValue.c)
108108
}
109109
}
110110

Tests/GRDBTests/RowFromDictionaryLiteralTests.swift

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class RowFromDictionaryLiteralTests : RowTestCase {
3939
XCTAssertEqual(row["a"] as Int, 0)
4040
}
4141

42-
func testRowValueAtIndex() {
42+
func testRowValueAtIndex() throws {
4343
let row: Row = ["a": 0, "b": 1, "c": 2]
4444

4545
let aIndex = row.distance(from: row.startIndex, to: row.firstIndex(where: { (column, value) in column == "a" })!)
@@ -52,22 +52,22 @@ class RowFromDictionaryLiteralTests : RowTestCase {
5252
assertRowRawValueEqual(row, index: cIndex, value: 2 as Int64)
5353

5454
// DatabaseValueConvertible & StatementColumnConvertible
55-
assertRowConvertedValueEqual(row, index: aIndex, value: 0 as Int)
56-
assertRowConvertedValueEqual(row, index: bIndex, value: 1 as Int)
57-
assertRowConvertedValueEqual(row, index: cIndex, value: 2 as Int)
55+
try assertRowConvertedValueEqual(row, index: aIndex, value: 0 as Int)
56+
try assertRowConvertedValueEqual(row, index: bIndex, value: 1 as Int)
57+
try assertRowConvertedValueEqual(row, index: cIndex, value: 2 as Int)
5858

5959
// DatabaseValueConvertible
60-
assertRowConvertedValueEqual(row, index: aIndex, value: CustomValue.a)
61-
assertRowConvertedValueEqual(row, index: bIndex, value: CustomValue.b)
62-
assertRowConvertedValueEqual(row, index: cIndex, value: CustomValue.c)
60+
try assertRowConvertedValueEqual(row, index: aIndex, value: CustomValue.a)
61+
try assertRowConvertedValueEqual(row, index: bIndex, value: CustomValue.b)
62+
try assertRowConvertedValueEqual(row, index: cIndex, value: CustomValue.c)
6363

6464
// Expect fatal error:
6565
//
6666
// row[-1]
6767
// row[3]
6868
}
6969

70-
func testRowValueNamed() {
70+
func testRowValueNamed() throws {
7171
let row: Row = ["a": 0, "b": 1, "c": 2]
7272

7373
// Raw extraction
@@ -76,17 +76,17 @@ class RowFromDictionaryLiteralTests : RowTestCase {
7676
assertRowRawValueEqual(row, name: "c", value: 2 as Int64)
7777

7878
// DatabaseValueConvertible & StatementColumnConvertible
79-
assertRowConvertedValueEqual(row, name: "a", value: 0 as Int)
80-
assertRowConvertedValueEqual(row, name: "b", value: 1 as Int)
81-
assertRowConvertedValueEqual(row, name: "c", value: 2 as Int)
79+
try assertRowConvertedValueEqual(row, name: "a", value: 0 as Int)
80+
try assertRowConvertedValueEqual(row, name: "b", value: 1 as Int)
81+
try assertRowConvertedValueEqual(row, name: "c", value: 2 as Int)
8282

8383
// DatabaseValueConvertible
84-
assertRowConvertedValueEqual(row, name: "a", value: CustomValue.a)
85-
assertRowConvertedValueEqual(row, name: "b", value: CustomValue.b)
86-
assertRowConvertedValueEqual(row, name: "c", value: CustomValue.c)
84+
try assertRowConvertedValueEqual(row, name: "a", value: CustomValue.a)
85+
try assertRowConvertedValueEqual(row, name: "b", value: CustomValue.b)
86+
try assertRowConvertedValueEqual(row, name: "c", value: CustomValue.c)
8787
}
8888

89-
func testRowValueFromColumn() {
89+
func testRowValueFromColumn() throws {
9090
let row: Row = ["a": 0, "b": 1, "c": 2]
9191

9292
// Raw extraction
@@ -95,14 +95,14 @@ class RowFromDictionaryLiteralTests : RowTestCase {
9595
assertRowRawValueEqual(row, column: Column("c"), value: 2 as Int64)
9696

9797
// DatabaseValueConvertible & StatementColumnConvertible
98-
assertRowConvertedValueEqual(row, column: Column("a"), value: 0 as Int)
99-
assertRowConvertedValueEqual(row, column: Column("b"), value: 1 as Int)
100-
assertRowConvertedValueEqual(row, column: Column("c"), value: 2 as Int)
98+
try assertRowConvertedValueEqual(row, column: Column("a"), value: 0 as Int)
99+
try assertRowConvertedValueEqual(row, column: Column("b"), value: 1 as Int)
100+
try assertRowConvertedValueEqual(row, column: Column("c"), value: 2 as Int)
101101

102102
// DatabaseValueConvertible
103-
assertRowConvertedValueEqual(row, column: Column("a"), value: CustomValue.a)
104-
assertRowConvertedValueEqual(row, column: Column("b"), value: CustomValue.b)
105-
assertRowConvertedValueEqual(row, column: Column("c"), value: CustomValue.c)
103+
try assertRowConvertedValueEqual(row, column: Column("a"), value: CustomValue.a)
104+
try assertRowConvertedValueEqual(row, column: Column("b"), value: CustomValue.b)
105+
try assertRowConvertedValueEqual(row, column: Column("c"), value: CustomValue.c)
106106
}
107107

108108
func testWithUnsafeData() throws {

Tests/GRDBTests/RowFromDictionaryTests.swift

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class RowFromDictionaryTests : RowTestCase {
2626
XCTAssertEqual(bools, [false, true, true])
2727
}
2828

29-
func testRowValueAtIndex() {
29+
func testRowValueAtIndex() throws {
3030
let dictionary: [String: (any DatabaseValueConvertible)?] = ["a": 0, "b": 1, "c": 2]
3131
let row = Row(dictionary)
3232

@@ -40,22 +40,22 @@ class RowFromDictionaryTests : RowTestCase {
4040
assertRowRawValueEqual(row, index: cIndex, value: 2 as Int64)
4141

4242
// DatabaseValueConvertible & StatementColumnConvertible
43-
assertRowConvertedValueEqual(row, index: aIndex, value: 0 as Int)
44-
assertRowConvertedValueEqual(row, index: bIndex, value: 1 as Int)
45-
assertRowConvertedValueEqual(row, index: cIndex, value: 2 as Int)
43+
try assertRowConvertedValueEqual(row, index: aIndex, value: 0 as Int)
44+
try assertRowConvertedValueEqual(row, index: bIndex, value: 1 as Int)
45+
try assertRowConvertedValueEqual(row, index: cIndex, value: 2 as Int)
4646

4747
// DatabaseValueConvertible
48-
assertRowConvertedValueEqual(row, index: aIndex, value: CustomValue.a)
49-
assertRowConvertedValueEqual(row, index: bIndex, value: CustomValue.b)
50-
assertRowConvertedValueEqual(row, index: cIndex, value: CustomValue.c)
48+
try assertRowConvertedValueEqual(row, index: aIndex, value: CustomValue.a)
49+
try assertRowConvertedValueEqual(row, index: bIndex, value: CustomValue.b)
50+
try assertRowConvertedValueEqual(row, index: cIndex, value: CustomValue.c)
5151

5252
// Expect fatal error:
5353
//
5454
// row[-1]
5555
// row[3]
5656
}
5757

58-
func testRowValueNamed() {
58+
func testRowValueNamed() throws {
5959
let row = Row(["a": 0, "b": 1, "c": 2])
6060

6161
// Raw extraction
@@ -64,17 +64,17 @@ class RowFromDictionaryTests : RowTestCase {
6464
assertRowRawValueEqual(row, name: "c", value: 2 as Int64)
6565

6666
// DatabaseValueConvertible & StatementColumnConvertible
67-
assertRowConvertedValueEqual(row, name: "a", value: 0 as Int)
68-
assertRowConvertedValueEqual(row, name: "b", value: 1 as Int)
69-
assertRowConvertedValueEqual(row, name: "c", value: 2 as Int)
67+
try assertRowConvertedValueEqual(row, name: "a", value: 0 as Int)
68+
try assertRowConvertedValueEqual(row, name: "b", value: 1 as Int)
69+
try assertRowConvertedValueEqual(row, name: "c", value: 2 as Int)
7070

7171
// DatabaseValueConvertible
72-
assertRowConvertedValueEqual(row, name: "a", value: CustomValue.a)
73-
assertRowConvertedValueEqual(row, name: "b", value: CustomValue.b)
74-
assertRowConvertedValueEqual(row, name: "c", value: CustomValue.c)
72+
try assertRowConvertedValueEqual(row, name: "a", value: CustomValue.a)
73+
try assertRowConvertedValueEqual(row, name: "b", value: CustomValue.b)
74+
try assertRowConvertedValueEqual(row, name: "c", value: CustomValue.c)
7575
}
7676

77-
func testRowValueFromColumn() {
77+
func testRowValueFromColumn() throws {
7878
let row = Row(["a": 0, "b": 1, "c": 2])
7979

8080
// Raw extraction
@@ -83,14 +83,14 @@ class RowFromDictionaryTests : RowTestCase {
8383
assertRowRawValueEqual(row, column: Column("c"), value: 2 as Int64)
8484

8585
// DatabaseValueConvertible & StatementColumnConvertible
86-
assertRowConvertedValueEqual(row, column: Column("a"), value: 0 as Int)
87-
assertRowConvertedValueEqual(row, column: Column("b"), value: 1 as Int)
88-
assertRowConvertedValueEqual(row, column: Column("c"), value: 2 as Int)
86+
try assertRowConvertedValueEqual(row, column: Column("a"), value: 0 as Int)
87+
try assertRowConvertedValueEqual(row, column: Column("b"), value: 1 as Int)
88+
try assertRowConvertedValueEqual(row, column: Column("c"), value: 2 as Int)
8989

9090
// DatabaseValueConvertible
91-
assertRowConvertedValueEqual(row, column: Column("a"), value: CustomValue.a)
92-
assertRowConvertedValueEqual(row, column: Column("b"), value: CustomValue.b)
93-
assertRowConvertedValueEqual(row, column: Column("c"), value: CustomValue.c)
91+
try assertRowConvertedValueEqual(row, column: Column("a"), value: CustomValue.a)
92+
try assertRowConvertedValueEqual(row, column: Column("b"), value: CustomValue.b)
93+
try assertRowConvertedValueEqual(row, column: Column("c"), value: CustomValue.c)
9494
}
9595

9696
func testWithUnsafeData() throws {

0 commit comments

Comments
 (0)