forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatToolExecutorRowIntTests.swift
More file actions
37 lines (31 loc) · 1.46 KB
/
Copy pathChatToolExecutorRowIntTests.swift
File metadata and controls
37 lines (31 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import XCTest
@testable import Omi_Computer
/// Regression coverage for `ChatToolExecutor.rowInt`. GRDB decodes SQLite
/// INTEGER columns (including COUNT/MIN/MAX aggregates) to `Int64`, and
/// `Int64 as? Int` is ALWAYS nil in Swift — no numeric bridging. So the daily
/// recap / file-scan tools that read row integers with a bare `row["col"] as? Int`
/// silently reported 0 captures, unchecked ("done") tasks as not done, 0m focus
/// durations, and "0 files" per type. `rowInt` reads the value correctly.
final class ChatToolExecutorRowIntTests: XCTestCase {
func testInt64AsIntNeverBridges() {
// The exact defect the helper exists to work around. Cast from an `Any`
// box (as production does with a GRDB row value) — spelling `Int64 as? Int`
// directly is diagnosed as an always-failing cast under -warnings-as-errors.
let boxed: Any = Int64(7)
XCTAssertNil(boxed as? Int)
}
func testRowIntExtractsInt64Value() {
XCTAssertEqual(ChatToolExecutor.rowInt(Int64(7)), 7)
XCTAssertEqual(ChatToolExecutor.rowInt(Int64(0)), 0)
XCTAssertEqual(ChatToolExecutor.rowInt(Int64(-3)), -3)
}
func testRowIntFallsBackToPlainInt() {
// Defensive: an already-`Int` value still reads.
XCTAssertEqual(ChatToolExecutor.rowInt(Int(42)), 42)
}
func testRowIntReturnsNilForMissingOrNonInteger() {
XCTAssertNil(ChatToolExecutor.rowInt(nil))
XCTAssertNil(ChatToolExecutor.rowInt("123"))
XCTAssertNil(ChatToolExecutor.rowInt(3.5))
}
}