Files
bot/apps/shared/OpenClawKit/Tests/OpenClawKitTests/AnyCodableTests.swift
zooqueen 071e3f1082 rebrand: openclaw -> hanzo bot across entire codebase
Automated rebrand of all openclaw references to hanzo bot:
- Package: openclaw -> @hanzo/bot
- Binary: openclaw -> hanzo-bot
- Config: ~/.openclaw -> ~/.hanzo/bot
- Docker: ghcr.io/hanzoai/bot
- Env vars: OPENCLAW_* -> BOT_*
- Bundle IDs: ai.hanzo.bot.*
- Product name: Hanzo Bot
2026-03-19 13:52:32 -07:00

41 lines
1.3 KiB
Swift

import Foundation
import Testing
import Hanzo 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"#))
}
}