mirror of
https://github.com/hanzoai/bot.git
synced 2026-10-30 17:24:26 +00:00
Merged 3580 upstream commits from openclaw/main through a bridge branch that applied the openclaw→hanzo-bot rebrand before merging. Key upstream additions: - Android device diagnostics and notification actions - Device-auth v2 migration improvements - Docker CLI packaging fixes - Ollama discovery log demotion - Channel health monitoring - Slack native streaming - Linq iMessage channel - Gemini OAuth and FTS improvements - Inbound sender metadata - Daemon PATH improvements - Canvas host and onboarding enhancements - Security hardening (session files, exec allowlist)
41 lines
1.3 KiB
Swift
41 lines
1.3 KiB
Swift
import Foundation
|
|
import Testing
|
|
import BotProtocol
|
|
|
|
struct AnyCodableTests {
|
|
@Test
|
|
func encodesNSNumberBooleansAsJSONBooleans() throws {
|
|
let trueData = try JSONEncoder().encode(AnyCodable(NSNumber(value: true)))
|
|
let falseData = try JSONEncoder().encode(AnyCodable(NSNumber(value: false)))
|
|
|
|
#expect(String(data: trueData, encoding: .utf8) == "true")
|
|
#expect(String(data: falseData, encoding: .utf8) == "false")
|
|
}
|
|
|
|
@Test
|
|
func preservesBooleanLiteralsFromJSONSerializationBridge() throws {
|
|
let raw = try #require(
|
|
JSONSerialization.jsonObject(with: Data(#"{"enabled":true,"nested":{"active":false}}"#.utf8))
|
|
as? [String: Any]
|
|
)
|
|
let enabled = try #require(raw["enabled"])
|
|
let nested = try #require(raw["nested"])
|
|
|
|
struct RequestEnvelope: Codable {
|
|
let params: [String: AnyCodable]
|
|
}
|
|
|
|
let envelope = RequestEnvelope(
|
|
params: [
|
|
"enabled": AnyCodable(enabled),
|
|
"nested": AnyCodable(nested),
|
|
]
|
|
)
|
|
let data = try JSONEncoder().encode(envelope)
|
|
let json = try #require(String(data: data, encoding: .utf8))
|
|
|
|
#expect(json.contains(#""enabled":true"#))
|
|
#expect(json.contains(#""active":false"#))
|
|
}
|
|
}
|