Skip to content

armgit / xtool

Public Imported from GitHub
0

Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.

1.6 KB
Raw Blame
import Testing
@testable import XToolSupport

extension SDKEntry {
    fileprivate static let test = E("Root", [
        E("Intermediate", [
            E("Leaf"),
        ]),
        E("AnotherLeaf"),
        E("BeforeWildcard", [
            E(nil, [
                E("AfterWildcard"),
            ]),
        ]),
    ])
}

@Test func testMatcherSupportsSlices() {
    let s = SDKEntry.test

    let slice0 = ["Root"].map { $0[...] }[0...]
    #expect(s.matches(slice0))

    let slice1 = ["foo", "bar", "Root"].map { $0[...] }[2...]
    #expect(s.matches(slice1))

    let slice2 = ["foo", "bar", "NotRoot"].map { $0[...] }[2...]
    #expect(!s.matches(slice2))
}

@Test func testMatcherLeaves() {
    let s = SDKEntry.test

    #expect(s.matches(["Root", "Intermediate"]))
    #expect(!s.matches(["Root", "NotIntermediate"]))

    #expect(s.matches(["Root", "Intermediate", "Leaf"]))
    #expect(!s.matches(["Root", "Intermediate", "NotLeaf"]))
    #expect(s.matches(["Root", "Intermediate", "Leaf", "AfterLeaf"]))

    #expect(s.matches(["Root", "AnotherLeaf"]))
    #expect(s.matches(["Root", "AnotherLeaf", "AfterAnotherLeaf"]))

    #expect(!s.matches(["Junk", "Root"]))

    #expect(s.matches(["Root", "BeforeWildcard"]))
    #expect(s.matches(["Root", "BeforeWildcard", "Blah"]))
    #expect(s.matches(["Root", "BeforeWildcard", "Blah", "AfterWildcard"]))
    #expect(s.matches(["Root", "BeforeWildcard", "Blah", "AfterWildcard", "Suffix"]))
    #expect(!s.matches(["Root", "BeforeWildcard", "Blah", "NotAfterWildcard"]))
    #expect(!s.matches(["Root", "BeforeWildcard", "Blah", "NotAfterWildcard", "Suffix"]))
}