Refactor entire codebase and rewrite documentation

This commit is contained in:
2025-10-10 18:06:34 +03:00
parent b4e9755c15
commit 8e471f2b9f
74 changed files with 3405 additions and 4149 deletions

View File

@@ -1,27 +0,0 @@
import Testing
import DataLiteC
import DataLiteCore
struct SQLiteRawTypeTests {
@Test func testInitializationFromRawValue() {
#expect(SQLiteRawType(rawValue: SQLITE_INTEGER) == .int)
#expect(SQLiteRawType(rawValue: SQLITE_FLOAT) == .real)
#expect(SQLiteRawType(rawValue: SQLITE_TEXT) == .text)
#expect(SQLiteRawType(rawValue: SQLITE_BLOB) == .blob)
#expect(SQLiteRawType(rawValue: SQLITE_NULL) == .null)
#expect(SQLiteRawType(rawValue: -1) == nil)
}
@Test func testRawValue() {
#expect(SQLiteRawType.int.rawValue == SQLITE_INTEGER)
#expect(SQLiteRawType.real.rawValue == SQLITE_FLOAT)
#expect(SQLiteRawType.text.rawValue == SQLITE_TEXT)
#expect(SQLiteRawType.blob.rawValue == SQLITE_BLOB)
#expect(SQLiteRawType.null.rawValue == SQLITE_NULL)
}
@Test func testInvalidRawValue() {
let invalidRawValue: Int32 = 9999
#expect(SQLiteRawType(rawValue: invalidRawValue) == nil)
}
}

View File

@@ -1,36 +0,0 @@
import Testing
import Foundation
import DataLiteCore
struct SQLiteRawValueTests {
@Test func testIntValue() {
let value = SQLiteRawValue.int(42)
#expect(value.description == "42")
}
@Test func testRealValue() {
let value = SQLiteRawValue.real(3.14)
#expect(value.description == "3.14")
}
@Test func testTextValue() {
let value = SQLiteRawValue.text("Hello, World!")
#expect(value.description == "'Hello, World!'")
}
@Test func testTextValueWithSingleQuote() {
let value = SQLiteRawValue.text("O'Reilly")
#expect(value.description == "'O''Reilly'") // Escaped single quote
}
@Test func testBlobValue() {
let data = Data([0xDE, 0xAD, 0xBE, 0xEF])
let value = SQLiteRawValue.blob(data)
#expect(value.description == "X'DEADBEEF'")
}
@Test func testNullValue() {
let value = SQLiteRawValue.null
#expect(value.description == "NULL")
}
}

View File

@@ -0,0 +1,49 @@
import Foundation
import Testing
import DataLiteCore
struct SQLiteValueTests {
@Test(arguments: [1, 42, 1234])
func testSQLiteIntValue(_ value: Int64) {
let value = SQLiteValue.int(value)
#expect(value.sqliteLiteral == "\(value)")
#expect(value.description == value.sqliteLiteral)
}
@Test(arguments: [12, 0.5, 123.99])
func testSQLiteRealValue(_ value: Double) {
let value = SQLiteValue.real(value)
#expect(value.sqliteLiteral == "\(value)")
#expect(value.description == value.sqliteLiteral)
}
@Test(arguments: [
("", "''"),
("'hello'", "'''hello'''"),
("hello", "'hello'"),
("O'Reilly", "'O''Reilly'"),
("It's John's \"book\"", "'It''s John''s \"book\"'")
])
func testSQLiteTextValue(_ value: String, _ expected: String) {
let value = SQLiteValue.text(value)
#expect(value.sqliteLiteral == expected)
#expect(value.description == value.sqliteLiteral)
}
@Test(arguments: [
(Data(), "X''"),
(Data([0x00]), "X'00'"),
(Data([0x00, 0xAB, 0xCD]), "X'00ABCD'")
])
func testSQLiteBlobValue(_ value: Data, _ expected: String) {
let value = SQLiteValue.blob(value)
#expect(value.sqliteLiteral == expected)
#expect(value.description == value.sqliteLiteral)
}
@Test func testSQLiteNullValue() {
let value = SQLiteValue.null
#expect(value.sqliteLiteral == "NULL")
#expect(value.description == value.sqliteLiteral)
}
}