Add unit tests

This commit is contained in:
2025-10-25 18:56:55 +03:00
parent ddc47abdde
commit bbb7f14650
38 changed files with 1051 additions and 526 deletions

View File

@@ -4,15 +4,15 @@ import DataLiteC
import DataLiteCore
struct StatementOptionsTests {
@Test func testPersistentOptions() {
@Test func persistentOptions() {
#expect(Statement.Options.persistent.rawValue == UInt32(SQLITE_PREPARE_PERSISTENT))
}
@Test func testNoVtabOptions() {
@Test func noVtabOptions() {
#expect(Statement.Options.noVtab.rawValue == UInt32(SQLITE_PREPARE_NO_VTAB))
}
@Test func testCombineOptions() {
@Test func combineOptions() {
let options: Statement.Options = [.persistent, .noVtab]
let expected = UInt32(SQLITE_PREPARE_PERSISTENT | SQLITE_PREPARE_NO_VTAB)
#expect(options.contains(.persistent))
@@ -20,19 +20,19 @@ struct StatementOptionsTests {
#expect(options.rawValue == expected)
}
@Test func testInitWithUInt32RawValue() {
@Test func initWithUInt32RawValue() {
let raw = UInt32(SQLITE_PREPARE_PERSISTENT)
let options = Statement.Options(rawValue: raw)
#expect(options == .persistent)
}
@Test func testInitWithInt32RawValue() {
@Test func initWithInt32RawValue() {
let raw = Int32(SQLITE_PREPARE_NO_VTAB)
let options = Statement.Options(rawValue: raw)
#expect(options == .noVtab)
}
@Test func testEmptySetRawValueIsZero() {
@Test func emptySetRawValueIsZero() {
let empty: Statement.Options = []
#expect(empty.rawValue == 0)
#expect(!empty.contains(.persistent))