add swiftUI code

This commit is contained in:
zeus
2025-01-22 14:09:10 +08:00
parent 68e7b7347c
commit 8a99853829
2531 changed files with 486215 additions and 0 deletions
@@ -0,0 +1,29 @@
import XCTest
import GRDB
class ValueObservationMapTests: GRDBTestCase {
func testMap() throws {
let valueObservation = ValueObservation
.trackingConstantRegion(Table("t").fetchCount)
.map { "\($0)" }
try assertValueObservation(
valueObservation,
records: ["0", "1", "2"],
setup: { db in
try db.execute(sql: "CREATE TABLE t(id INTEGER PRIMARY KEY AUTOINCREMENT)")
},
recordedUpdates: { db in
try db.execute(sql: "INSERT INTO t DEFAULT VALUES")
try db.execute(sql: "INSERT INTO t DEFAULT VALUES")
})
}
func testMapPreservesConfiguration() {
var observation = ValueObservation.trackingConstantRegion { _ in }
observation.requiresWriteAccess = true
let mappedObservation = observation.map { _ in }
XCTAssertEqual(mappedObservation.requiresWriteAccess, observation.requiresWriteAccess)
}
}