Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : Claude Remote / Codex Remote9// File : Packages/ClaudeRemoteKit/Tests/ModelsTests/OpenEnumTests.swift10// Module : ModelsTests11// Repository : https://git.spboucher.ai/claude-remote-apple12// Project Website : https://claude.spboucher.ai13// Created : 2026-11-2914// Last Modified : 2026-11-2915//16// =============================================================================17// AUTHOR & PROFESSIONAL AFFILIATION18// =============================================================================19//20// Author : Simon-Pierre Boucher21// Position : Professor of Finance22// Institution : Université du Québec en Outaouais (UQO)23// Department : Département des sciences administratives24// Organization : SP Boucher25//26// Website : https://spboucher.ai27// Git : https://git.spboucher.ai28//29// =============================================================================30// OFFICIAL CONTACT DIRECTORY31// =============================================================================32//33// General : info@spboucher.ai34// Professional : contact@spboucher.ai35// Direct : simon@spboucher.ai36// Research : research@spboucher.ai37// Development : dev@spboucher.ai38// Support : support@spboucher.ai39// Security/Admin : admin@spboucher.ai40// Notifications : notifications@spboucher.ai41//42// Preferred Contact: support@spboucher.ai43//44// =============================================================================45// COPYRIGHT & INTELLECTUAL PROPERTY46// =============================================================================47//48// Copyright (c) 202649// Simon-Pierre Boucher50//51// All rights reserved where applicable.52//53// This file is governed by the applicable project license,54// copyright notices, institutional agreements and relevant law.55//56// Unless expressly authorized by the applicable license or57// rights holder, copying, redistribution, sublicensing,58// publication and commercial exploitation are not permitted.59//60// Existing third-party rights and notices remain unaffected.61//62// =============================================================================63// CONFIDENTIALITY & SECURITY64// =============================================================================65//66// Classification : Public67// Distribution : Public repository; use is governed by the project license68// Security Contact : admin@spboucher.ai69//70// Access to this source does not independently grant permission71// to redistribute or disclose confidential materials.72//73// Do not embed credentials, private keys, access tokens,74// certificates or confidential personal information.75//76// =============================================================================77// LICENSE & MAINTENANCE78// =============================================================================79//80// License : None specified (no license file in this repository)81// Maintainer : Simon-Pierre Boucher82// Technical Contact: dev@spboucher.ai83//84// =============================================================================85// END OF SP BOUCHER SOURCE HEADER86// =============================================================================8788import ClaudeRemoteModels89import Foundation90import Testing9192@Suite("Open string enums")93struct OpenEnumTests {94 @Test func rawValuesRoundTrip() throws {95 #expect(SessionState.running.rawValue == "RUNNING")96 #expect(SessionState("WAITING_FOR_INPUT") == .waitingForInput)97 #expect(SessionState("PAUSED") == .unknown("PAUSED"))98 #expect(SessionState.unknown("PAUSED").rawValue == "PAUSED")99 #expect(!SessionState("PAUSED").isKnown)100 #expect(SessionState.allCases.count == 9)101 #expect(Set([SessionState.running, .running, .stopped]).count == 2)102 #expect(SessionKind.agent.rawValue == "claude")103 #expect(Health("UNKNOWN") == .unknownHealth)104 #expect(McpStatus("unknown") == .notChecked)105 }106107 @Test func codableKeepsUnknownValues() throws {108 let decoded = try JSONDecoder().decode([TaskState].self, from: Data(#"["QUEUED","TIMED_OUT","PREEMPTED"]"#.utf8))109 #expect(decoded == [.queued, .timedOut, .unknown("PREEMPTED")])110 let encoded = String(decoding: try JSONEncoder().encode(decoded), as: UTF8.self)111 #expect(encoded == #"["QUEUED","TIMED_OUT","PREEMPTED"]"#)112 }113114 @Test func everyKnownCaseOfEveryEnumRoundTrips() {115 func check<E: OpenStringEnum>(_ type: E.Type) {116 for (value, raw) in E.known {117 #expect(value.rawValue == raw)118 #expect(E(raw) == value)119 #expect(value.isKnown)120 }121 #expect(Set(E.known.map(\.1)).count == E.known.count)122 }123 check(SessionState.self); check(TaskState.self); check(Health.self); check(AgentID.self); check(McpTransport.self)124 check(SkillKind.self); check(LoginNext.self); check(DeviceKind.self); check(NativePlatform.self); check(SessionKind.self)125 check(FileEntryType.self); check(ClusterNodeKind.self); check(ClusterSource.self); check(ClusterEdgeKind.self)126 check(ClusterAppState.self); check(IncidentSeverity.self); check(SkillSource.self); check(McpScope.self); check(McpStatus.self)127 check(NotificationKind.self); check(ThemePreference.self); check(TerminalThemePreference.self); check(WorkspaceLayout.self)128 check(NotificationDetail.self)129 }130131 @Test func sessionStateSemantics() {132 #expect(SessionState.waitingForInput.isLive && SessionState.waitingForInput.isAttachable)133 #expect(SessionState.stopping.isLive && !SessionState.stopping.isAttachable)134 #expect(!SessionState.recoverable.isLive)135 #expect(SessionState.running.canTransition(to: .waitingForInput))136 #expect(!SessionState.stopped.canTransition(to: .running))137 #expect(SessionState.recoverable.canTransition(to: .starting))138 #expect(TaskState.timedOut.isFinished && !TaskState.cancelling.isFinished && TaskState.queued.canCancel)139 }140}141