-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Expected Behavior
Some empty dictionaries that have been encoded with CBOREncoder throw a type mismatch error when the data is decoded again with CBORDecoder.
To me this seems like a relatively severe bug.
Actual Behavior
See provided test methods.
Steps To Reproduce
Test methods I added to CBORDecoderTests. The first one currently fails, the second one succeeds.
/// Fails!
func testEmptyDictionaryRoundTripUInt64Key() throws {
let dict = [UInt64: String]()
let data = try CBOREncoder().encode(dict)
let dict2: [UInt64: String] = try CBORDecoder().decode(from: data)
XCTAssertEqual(dict, dict2)
}
/// Succeeds
func testEmptyDictionaryRoundTripIntKey() throws {
let dict = [Int: String]()
let data = try CBOREncoder().encode(dict)
let dict2: [Int: String] = try CBORDecoder().decode(from: data)
XCTAssertEqual(dict, dict2)
}
Other types fail too, for example dictionaries with Int32 keys.
Project Version
The OS/Variant where this issue occurs.
- iOS
- macOS
- tvOS
- watchOS
- Mac Catalyst
- Other (Please specify in "Additional Context" section)
The version of Xcode that was used when this issue appeared.
15.0.1 (15A507)
What was the environment in which the issue appeared?
- CBORCoding.xcodeproj
- Package.swift
- Carthage
- CocoaPods
- Swift Package Manager
- Other (Please specify in "Additional Context" section)
Additional Context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working