Files
Qiu YuzhouandDeepSeek Harness 78bafea90f test: drop assertions that restate the language or a fixture
Each removed assertion holds by construction and can never fail:

- jsonData() compared with itself cannot detect cross-run byte stability;
  bindAddress and mode are literal-returning computed properties
- RuleAction/RuleSourceKind allCases assertions pin synthesized enum order
  (neither allCases list is used in production); the persisted action tokens
  stay pinned by the kept rawValue assertions and source-kind tokens by
  fixture decoding through RuleSnapshotStore
- memberwise-constructor echo in RuleSourceIdentity, fixture-guaranteed
  name == id rows, a share draft field pair built from one string, and a
  local struct compared to its own assignment
- the synthesized-Codable round trip through literal JSONEncoder/JSONDecoder

The duplicate-import assertion becomes a real check: Set of node ids instead
of a count that restated roots.count, which is what its comment claims.

Co-Authored-By: DeepSeek Harness <noreply@deepseek.com>
2026-10-21 02:04:21 +08:00

37 lines
1.3 KiB
Swift

import XCTest
@testable import ShadowsocksX_NG2
/// 设置主缝:偏好校验与绕过列表解析只通过公开领域入口断言,不依赖
/// SwiftUI 视图实现。
final class ProxyRuntimeSettingsTests: XCTestCase {
func testFactoryDefaultsAvoidLegacyPortsAndValidate() {
let settings = ProxyRuntimeSettings()
XCTAssertEqual(settings.listen.socksPort, 11086)
XCTAssertEqual(settings.listen.httpPort, 11087)
XCTAssertFalse(settings.agentEnabled, "全新用户无服务器配置,Agent 默认 off")
XCTAssertFalse(settings.systemProxyEnabled)
XCTAssertTrue(settings.validationErrors.isEmpty)
}
func testProxyExceptionsSplitCommaChineseCommaAndWhitespaceWithoutDuplicates() {
var settings = ProxyRuntimeSettings()
settings.proxyExceptions = "localhost, 127.0.0.1、localhost\n::1"
XCTAssertEqual(settings.proxyExceptionList, ["localhost", "127.0.0.1", "::1"])
}
func testListenerModeDoesNotAddAddressTextValidation() {
var settings = ProxyRuntimeSettings()
settings.listen.listenerMode = .allIPv6Interfaces
settings.listen.socksPort = settings.listen.httpPort
XCTAssertEqual(
settings.validationErrors,
[
.duplicatePort(endpoint: .socks, otherEndpoint: .http, port: 11087)
])
}
}