-
Notifications
You must be signed in to change notification settings - Fork 112
Conditionally conform to Combine.TopLevelDecoder #132
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
Changes from all commits
e7e7528
53955d2
5a2be53
eba5465
ae8e76a
d3821f2
5994ae1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// CombineTests.swift | ||
// XMLCoder | ||
// | ||
// Created by Adam Sharp on 9/29/19. | ||
// | ||
|
||
#if canImport(Combine) && !os(macOS) | ||
import Combine | ||
import Foundation | ||
import XCTest | ||
import XMLCoder | ||
|
||
private let xml = """ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<foo> | ||
<name>Foo</name> | ||
</foo> | ||
""".data(using: .utf8)! | ||
|
||
private struct Foo: Decodable { | ||
var name: String | ||
} | ||
|
||
@available(iOS 13.0, macOS 10.15.0, tvOS 13.0, watchOS 6.0, *) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if the solution would be to remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing macOS from the availability annotation would instead result in a compiler error. The issue is that we successfully compile & link, but then attempt to run the tests on a platform where the framework doesn't exist and instead crash when the symbol can't be loaded. If we want to exclude the test from macOS altogether, we could add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Xcode 11 job already tests on macOS, iOS and tvOS, so that should be fine. |
||
class CombineTests: XCTestCase { | ||
func testDecodeFromXMLDecoder() { | ||
let data = Just(xml) | ||
var foo: Foo? | ||
_ = data.decode(type: Foo.self, decoder: XMLDecoder()).sink( | ||
receiveCompletion: { _ in }, | ||
receiveValue: { foo = $0 } | ||
) | ||
XCTAssertEqual(foo?.name, "Foo") | ||
} | ||
} | ||
#endif |
Uh oh!
There was an error while loading. Please reload this page.