DataLiteCore swift package

This commit is contained in:
2025-04-24 23:48:46 +03:00
parent b0e52a72b7
commit 6f955b2c43
70 changed files with 7939 additions and 1 deletions

View File

@@ -0,0 +1,50 @@
import Testing
import DataLiteCore
struct BinaryFloatingPointTests {
@Test func testFloatToSQLiteRawValue() {
let floatValue: Float = 3.14
let rawValue = floatValue.sqliteRawValue
#expect(rawValue == .real(Double(floatValue)))
}
@Test func testDoubleToSQLiteRawValue() {
let doubleValue: Double = 3.14
let rawValue = doubleValue.sqliteRawValue
#expect(rawValue == .real(doubleValue))
}
@Test func testFloatInitializationFromSQLiteRawValue() {
let realValue: SQLiteRawValue = .real(3.14)
let floatValue = Float(realValue)
#expect(floatValue != nil)
#expect(floatValue == 3.14)
let intValue: SQLiteRawValue = .int(42)
let floatFromInt = Float(intValue)
#expect(floatFromInt != nil)
#expect(floatFromInt == 42.0)
}
@Test func testDoubleInitializationFromSQLiteRawValue() {
let realValue: SQLiteRawValue = .real(3.14)
let doubleValue = Double(realValue)
#expect(doubleValue != nil)
#expect(doubleValue == 3.14)
let intValue: SQLiteRawValue = .int(42)
let doubleFromInt = Double(intValue)
#expect(doubleFromInt != nil)
#expect(doubleFromInt == 42.0)
}
@Test func testInitializationFailureFromInvalidSQLiteRawValue() {
let nullValue: SQLiteRawValue = .null
#expect(Float(nullValue) == nil)
#expect(Double(nullValue) == nil)
let textValue: SQLiteRawValue = .text("Invalid")
#expect(Float(textValue) == nil)
#expect(Double(textValue) == nil)
}
}