Skip to content

Commit 7793e5c

Browse files
committed
adding test for Boolean values support
1 parent 59bd776 commit 7793e5c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/jsTest/kotlin/cz/sazel/sqldelight/node/sqlite3/SQLite3DriverTest.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class SQLite3DriverTest {
3131
| integer_value INTEGER,
3232
| text_value TEXT,
3333
| blob_value BLOB,
34-
| real_value REAL
34+
| real_value REAL,
35+
| bool_value BOOLEAN
3536
|);
3637
""".trimMargin(),
3738
0,
@@ -178,7 +179,7 @@ class SQLite3DriverTest {
178179
@Test
179180
fun sqlResultSet_getters_return_null_if_the_column_values_are_NULL() = runTest { driver ->
180181
val insert: InsertFunction = { binders: SqlPreparedStatement.() -> Unit ->
181-
driver.await(7, "INSERT INTO nullability_test VALUES (?, ?, ?, ?, ?);", 5, binders)
182+
driver.await(7, "INSERT INTO nullability_test VALUES (?, ?, ?, ?, ?, ?);", 6, binders)
182183
}
183184

184185
suspend fun changes(mapper: suspend (SqlCursor) -> Long?): Long? {
@@ -191,6 +192,7 @@ class SQLite3DriverTest {
191192
bindString(2, null)
192193
bindBytes(3, null)
193194
bindDouble(4, null)
195+
bindBoolean(5, null)
194196
}
195197

196198
val mapper: suspend (SqlCursor) -> Unit = {
@@ -200,6 +202,7 @@ class SQLite3DriverTest {
200202
assertNull(it.getString(2))
201203
assertNull(it.getBytes(3))
202204
assertNull(it.getDouble(4))
205+
assertNull(it.getBoolean(5))
203206
}
204207
driver.awaitQuery(8, "SELECT * FROM nullability_test", mapper, 0)
205208
changes { it.next().await(); it.getLong(0) }
@@ -208,7 +211,7 @@ class SQLite3DriverTest {
208211
@Test
209212
fun types_are_correctly_converted_from_JS_to_Kotlin_and_back() = runTest { driver ->
210213
val insert: InsertFunction = { binders: SqlPreparedStatement.() -> Unit ->
211-
driver.await(7, "INSERT INTO nullability_test VALUES (?, ?, ?, ?, ?);", 5, binders)
214+
driver.await(7, "INSERT INTO nullability_test VALUES (?, ?, ?, ?, ?, ?);", 6, binders)
212215
}
213216

214217
insert {
@@ -217,6 +220,7 @@ class SQLite3DriverTest {
217220
bindString(2, "Hello")
218221
bindBytes(3, ByteArray(5) { it.toByte() })
219222
bindDouble(4, Float.MAX_VALUE.toDouble())
223+
bindBoolean(5, true)
220224
}
221225

222226
val mapper: suspend (SqlCursor) -> Unit = {
@@ -226,6 +230,7 @@ class SQLite3DriverTest {
226230
assertEquals("Hello", it.getString(2))
227231
it.getBytes(3)?.forEachIndexed { index, byte -> assertEquals(index.toByte(), byte) }
228232
assertEquals(Float.MAX_VALUE.toDouble(), it.getDouble(4))
233+
assertEquals(true, it.getBoolean(5))
229234
}
230235
driver.awaitQuery(8, "SELECT * FROM nullability_test", mapper, 0)
231236
}

0 commit comments

Comments
 (0)