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

Cleanup tests, support OpenCombine #169

Merged
merged 5 commits into from Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

4 changes: 4 additions & 0 deletions Sources/XMLCoder/Decoder/XMLDecoder.swift
Expand Up @@ -374,6 +374,10 @@ open class XMLDecoder {

#if canImport(Combine)
import protocol Combine.TopLevelDecoder
#elseif canImport(OpenCombine)
import protocol OpenCombine.TopLevelDecoder
#endif

#if canImport(Combine) || canImport(OpenCombine)
extension XMLDecoder: TopLevelDecoder {}
#endif
2 changes: 1 addition & 1 deletion Tests/XMLCoderTests/BenchmarkTests.swift
@@ -1,7 +1,7 @@
import XCTest
@testable import XMLCoder

class BenchmarkTests: XCTestCase {
final class BenchmarkTests: XCTestCase {
struct Container<T: Codable>: Codable {
let unkeyed: [T]
let keyed: [String: T]
Expand Down
2 changes: 1 addition & 1 deletion Tests/XMLCoderTests/ClassTests.swift
Expand Up @@ -90,7 +90,7 @@ private let xmlData = """
</s>
""".data(using: .utf8)!

class ClassTests: XCTestCase {
final class ClassTests: XCTestCase {
func testEmpty() throws {
let decoder = XMLDecoder()
let encoder = XMLEncoder()
Expand Down
9 changes: 7 additions & 2 deletions Tests/XMLCoderTests/CombineTests.swift
Expand Up @@ -5,8 +5,13 @@
// Created by Adam Sharp on 9/29/19.
//

#if canImport(Combine) && !os(macOS)
#if canImport(Combine)
import Combine
#elseif canImport(OpenCombine)
import OpenCombine
#endif

#if canImport(Combine) || canImport(OpenCombine)
import Foundation
import XCTest
import XMLCoder
Expand All @@ -23,7 +28,7 @@ private struct Foo: Decodable {
}

@available(iOS 13.0, macOS 10.15.0, tvOS 13.0, watchOS 6.0, *)
class CombineTests: XCTestCase {
final class CombineTests: XCTestCase {
func testDecodeFromXMLDecoder() {
let data = Just(xml)
var foo: Foo?
Expand Down
2 changes: 1 addition & 1 deletion Tests/XMLCoderTests/CompositeChoiceTests.swift
Expand Up @@ -47,7 +47,7 @@ extension IntOrStringWrapper: Codable {
}
}

class EnumAssociatedValueTestComposite: XCTestCase {
final class EnumAssociatedValueTestComposite: XCTestCase {
var encoder: XMLEncoder {
let encoder = XMLEncoder()
encoder.outputFormatting = [.prettyPrinted]
Expand Down
2 changes: 1 addition & 1 deletion Tests/XMLCoderTests/DecodingContainerTests.swift
Expand Up @@ -85,7 +85,7 @@ private struct Foo: Codable {
}
}

class DecodingContainerTests: XCTestCase {
final class DecodingContainerTests: XCTestCase {
func testExample() throws {
let foo = Foo(
foo: [
Expand Down
2 changes: 1 addition & 1 deletion Tests/XMLCoderTests/EmptyArrayTest.swift
Expand Up @@ -45,7 +45,7 @@ private let xmlContainsEmpty = """
</container>
"""

class EmptyArrayTest: XCTestCase {
final class EmptyArrayTest: XCTestCase {
func testEmptyArrayDecode() throws {
let decoded = try XMLDecoder().decode([Empty].self, from: xml.data(using: .utf8)!)
XCTAssertEqual(decoded, [Empty(), Empty(), Empty()])
Expand Down
2 changes: 1 addition & 1 deletion Tests/XMLCoderTests/EmptyElementEmptyStringTests.swift
Expand Up @@ -8,7 +8,7 @@
import XCTest
import XMLCoder

class EmptyElementEmptyStringTests: XCTestCase {
final class EmptyElementEmptyStringTests: XCTestCase {
struct ExplicitNestingContainer: Equatable, Decodable {
let things: ContainedArray

Expand Down
2 changes: 1 addition & 1 deletion Tests/XMLCoderTests/MixedChoiceAndNonChoiceTests.swift
Expand Up @@ -131,7 +131,7 @@ extension TwoChoiceElements: Codable {
}
}

class MixedChoiceAndNonChoiceTests: XCTestCase {
final class MixedChoiceAndNonChoiceTests: XCTestCase {
func testMixedChoiceFirstEncode() throws {
let first = MixedIntOrStringFirst(intOrString: .int(4), otherValue: "other")
let firstEncoded = try XMLEncoder().encode(first, withRootKey: "container")
Expand Down
2 changes: 1 addition & 1 deletion Tests/XMLCoderTests/NamespaceTest.swift
Expand Up @@ -251,7 +251,7 @@ private struct NamespacedRow: Codable {
}
}

class NameSpaceTest: XCTestCase {
final class NamespaceTest: XCTestCase {
func testTable() throws {
let decoder = XMLDecoder()
decoder.shouldProcessNamespaces = true
Expand Down
2 changes: 1 addition & 1 deletion Tests/XMLCoderTests/NestedAttributeChoiceTests.swift
Expand Up @@ -96,7 +96,7 @@ extension Entry: Codable {
}
}

class NestedAttributeChoiceTests: XCTestCase {
final class NestedAttributeChoiceTests: XCTestCase {
private var encoder: XMLEncoder {
let encoder = XMLEncoder()
encoder.outputFormatting = [.prettyPrinted]
Expand Down
2 changes: 1 addition & 1 deletion Tests/XMLCoderTests/NestedChoiceArrayTest.swift
Expand Up @@ -70,7 +70,7 @@ extension Book: Equatable {}
extension Chapter: Equatable {}
extension Chapter.Content: Equatable {}

class NestedChoiceArrayTest: XCTestCase {
final class NestedChoiceArrayTest: XCTestCase {
func testDecodingNestedChoiceArray() throws {
let xml = """
<?xml version="1.0" encoding="UTF-8"?>
Expand Down
2 changes: 1 addition & 1 deletion Tests/XMLCoderTests/NestedChoiceTests.swift
Expand Up @@ -83,7 +83,7 @@ extension Entry: Codable {
}
}

class NestedChoiceTests: XCTestCase {
final class NestedChoiceTests: XCTestCase {
func testBreakDecoding() throws {
let xml = "<br></br>"
let result = try XMLDecoder().decode(Break.self, from: xml.data(using: .utf8)!)
Expand Down
2 changes: 1 addition & 1 deletion Tests/XMLCoderTests/RJITest.swift
Expand Up @@ -140,7 +140,7 @@ private struct Enclosure: Codable, Equatable {
let type: String
}

class RJITest: XCTestCase {
final class RJITest: XCTestCase {
func testRSS() throws {
let decoder = XMLDecoder()
// let encoder = XMLEncoder()
Expand Down
2 changes: 1 addition & 1 deletion Tests/XMLCoderTests/RootLevelAttributeTest.swift
Expand Up @@ -32,7 +32,7 @@ let expected = """
</policy>
"""

class RootLevelAttributeTest: XCTestCase {
final class RootLevelAttributeTest: XCTestCase {
func testPolicyEncodingAtRoot() throws {
let encoder = XMLEncoder()
encoder.outputFormatting = [.prettyPrinted]
Expand Down
2 changes: 1 addition & 1 deletion Tests/XMLCoderTests/SimpleChoiceTests.swift
Expand Up @@ -8,7 +8,7 @@
import XCTest
import XMLCoder

class SimpleChoiceTests: XCTestCase {
final class SimpleChoiceTests: XCTestCase {
func testIntOrStringIntDecoding() throws {
let xml = """
<container>
Expand Down
26 changes: 23 additions & 3 deletions Tests/XMLCoderTests/XCTestManifests.swift
Expand Up @@ -120,6 +120,15 @@ extension BreakfastTest {
]
}

extension CDATATest {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__CDATATest = [
("testXML", testXML),
]
}

extension CDTest {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
Expand Down Expand Up @@ -439,11 +448,20 @@ extension MixedContainerTest {
]
}

extension NameSpaceTest {
extension MixedContentTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__MixedContentTests = [
("testMixed", testMixed),
]
}

extension NamespaceTest {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__NameSpaceTest = [
static let __allTests__NamespaceTest = [
("testTable", testTable),
("testTableWithoutNamespaces", testTableWithoutNamespaces),
("testWorksheet", testWorksheet),
Expand Down Expand Up @@ -832,6 +850,7 @@ public func __allTests() -> [XCTestCaseEntry] {
testCase(BorderTest.__allTests__BorderTest),
testCase(BoxTreeTests.__allTests__BoxTreeTests),
testCase(BreakfastTest.__allTests__BreakfastTest),
testCase(CDATATest.__allTests__CDATATest),
testCase(CDTest.__allTests__CDTest),
testCase(ClassTests.__allTests__ClassTests),
testCase(DataBoxTests.__allTests__DataBoxTests),
Expand All @@ -858,7 +877,8 @@ public func __allTests() -> [XCTestCaseEntry] {
testCase(KeyedTests.__allTests__KeyedTests),
testCase(MixedChoiceAndNonChoiceTests.__allTests__MixedChoiceAndNonChoiceTests),
testCase(MixedContainerTest.__allTests__MixedContainerTest),
testCase(NameSpaceTest.__allTests__NameSpaceTest),
testCase(MixedContentTests.__allTests__MixedContentTests),
testCase(NamespaceTest.__allTests__NamespaceTest),
testCase(NestedAttributeChoiceTests.__allTests__NestedAttributeChoiceTests),
testCase(NestedChoiceArrayTest.__allTests__NestedChoiceArrayTest),
testCase(NestedChoiceTests.__allTests__NestedChoiceTests),
Expand Down