PureYAML/Tests/UnkeyedContainerEdgeTests.swift
Mihaela M 934c9eafa3 test: cover numeric ladder, NaN hashing, unkeyed edges, error paths
Fill the highest-value coverage gaps found in the Codable bridge and
parser: the full integer-width decode ladder and per-width out-of-range
errors, Float round-trip, NaN equality and hash consistency (the bespoke
nan == nan invariant), unkeyed decodeNil false-branch and nested-index
mismatch, and the previously untested expectedNode, unterminated flow
mapping, explicit block-scalar under-indent, and buffered invalid-merge
error paths.
2026-06-26 07:50:08 +02:00

24 lines
922 B
Swift

@testable import PureYAML
import Testing
@Suite("Unkeyed Container Edges")
struct UnkeyedContainerEdgeTests {
@Test("decodeNil returns false for present values and still decodes them")
func test_unkeyedDecodeNilFalseBranchDecodesPresentValues() throws {
let decoded = try PureYAML.decode([Int?].self, from: .sequence([.int(1), .null, .int(2)]))
#expect(decoded == [1, nil, 2])
}
@Test("A nested unkeyed container type mismatch reports the index path")
func test_unkeyedNestedContainerMismatchReportsIndexPath() {
do {
_ = try PureYAML.decode([[Int]].self, from: .sequence([.int(1)]))
Issue.record("expected a decoding error")
} catch let error as PureYAML.Decoding.Error {
#expect(error.description == "Expected sequence at $[0], found int")
} catch {
Issue.record("unexpected error \(error)")
}
}
}