New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for nested keyed/unkeyed collections #38
Add tests for nested keyed/unkeyed collections #38
Conversation
These tests currently cause XMLCoder to hard crash with a fatal error. |
There were way too many functions returning `throw -> _?` in `XMLDecoder`, which should only ever return `throw -> _` (turning the `nil` case into an error of its own). 👷🏻♀️ I also managed to get rid of quite a bunch of force-unwraps. Especially the ones eventually leading to crashes in #38 and #34. 💥 * Make error handling in `XMLDecoder` simpler & safer * SwiftFormat and related cleanup
@regexident, I've rebased this on top of master and fixed SwiftFormat issues, but haven't fixed the tests. FYI, I've done a force-push, which was a mistake on my side. Please feel free to continue on top of that rebased work or overwrite with your own force-push if you had more commits pending. Hope this didn't disrupt your work. I'll try to avoid force-pushes to PR branches with other collaborators in the future, didn't realise early enough that this PR is work in progress. |
Oh, no worries. I didn't have any further local commits on the branch. |
For what it's worth I went ahead and added a pre-commit hook running |
… nested-container-tests # Conflicts: # XMLCoder.xcodeproj/project.pbxproj
Codecov Report
@@ Coverage Diff @@
## master #38 +/- ##
==========================================
+ Coverage 75.77% 75.82% +0.04%
==========================================
Files 38 38
Lines 2039 2039
==========================================
+ Hits 1545 1546 +1
+ Misses 494 493 -1
Continue to review full report at Codecov.
|
`UnkeyedBox` is a wrapper for `[Box]`, the assumption is that adding direct `Box` conformance to `[Box]` would simplify things a bit. Also, `KeyedStorage` now always stores `[Box]` per key without any special handling for single items per key to simplify this even more. In addition, order of values is preserved for all keys as required for #91 and #25. This should also unblock #101 providing unified handling for elements without any content and attributes. By pure serendipity this also fixes tests introduced in #38. * Replace UnkeyedBox with Array, refine KeyedStorage * Fix more of the broken tests * One unfixed test left in benchmarks * Single out failing benchmark in a separate test * Fix all tests 🎉 * Fix compiler warning * Fix Xcode 10.1 compilation error * Remove unused AnyArray protocol * Remove unused elementType function * Simplify code to improve test coverage
…container-tests # Conflicts: # Sources/XMLCoder/Auxiliaries/KeyedStorage.swift # Sources/XMLCoder/Auxiliaries/Metatypes.swift # Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift
`UnkeyedBox` is a wrapper for `[Box]`, the assumption is that adding direct `Box` conformance to `[Box]` would simplify things a bit. Also, `KeyedStorage` now always stores `[Box]` per key without any special handling for single items per key to simplify this even more. In addition, order of values is preserved for all keys as required for CoreOffice#91 and CoreOffice#25. This should also unblock CoreOffice#101 providing unified handling for elements without any content and attributes. By pure serendipity this also fixes tests introduced in CoreOffice#38. * Replace UnkeyedBox with Array, refine KeyedStorage * Fix more of the broken tests * One unfixed test left in benchmarks * Single out failing benchmark in a separate test * Fix all tests 🎉 * Fix compiler warning * Fix Xcode 10.1 compilation error * Remove unused AnyArray protocol * Remove unused elementType function * Simplify code to improve test coverage
CoreOffice#34 encounters a crasher when trying to decode nested arrays. This PR tries to add some more tests for nested keyed/unkeyed collections: - `[String: [Int]]` (dictionary of arrays) - `[String: [String: Int]]` (dictionary of dictionaries) - `[[Int]]` (array of arrays) - `[[String: Int]]` (array of dictionaries) * Added tests for nested complex (keyed/unkeyed) boxes * Fix trailing whitespace and indentation * Remove whitespace between doc comment and code * Avoid conflict in XMLDecoder.swift
PR #34 encounters a crasher when trying to decode nested arrays.
This PR tries to add some more tests for nested keyed/unkeyed collections.
What works: ✅
[String: [Int]]
(dictionary of arrays)[String: [String: Int]]
(dictionary of dictionaries)What crashes: ❌
[[Int]]
(array of arrays)[[String: Int]]
(array of dictionaries)