Skip to content
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

Merged
merged 17 commits into from May 22, 2019
Merged

Add tests for nested keyed/unkeyed collections #38

merged 17 commits into from May 22, 2019

Conversation

regexident
Copy link
Contributor

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)

@regexident
Copy link
Contributor Author

These tests currently cause XMLCoder to hard crash with a fatal error.
Merging #41 will cause the tests to just fail with an error.

MaxDesiatov pushed a commit that referenced this pull request Dec 23, 2018
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
@MaxDesiatov
Copy link
Collaborator

@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.

@regexident
Copy link
Contributor Author

Oh, no worries. I didn't have any further local commits on the branch.

@regexident
Copy link
Contributor Author

For what it's worth I went ahead and added a pre-commit hook running $ swiftformat . to my local repo. This should hopefully keep the need for formatting fix commits at a minimum from now on.

@MaxDesiatov MaxDesiatov changed the title Added tests for nested keyed/unkeyed collections Add tests for nested keyed/unkeyed collections Dec 26, 2018
@MaxDesiatov MaxDesiatov self-assigned this Apr 7, 2019
@codecov
Copy link

codecov bot commented May 21, 2019

Codecov Report

Merging #38 into master will increase coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
Sources/XMLCoder/Encoder/XMLEncoder.swift 80.95% <0%> (+0.95%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a673912...7ec0437. Read the comment docs.

MaxDesiatov added a commit that referenced this pull request May 22, 2019
`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
@MaxDesiatov MaxDesiatov merged commit eb22efd into CoreOffice:master May 22, 2019
arjungupta0107 pushed a commit to salido/XMLCoder that referenced this pull request Jun 26, 2020
`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
arjungupta0107 pushed a commit to salido/XMLCoder that referenced this pull request Jun 26, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants