How to use testFnmatch_matchesRelativeDirectory_noTrailingSlash method of PathFnmatchTests class

Best Mockingbird code snippet using PathFnmatchTests.testFnmatch_matchesRelativeDirectory_noTrailingSlash

Run Mockingbird automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

PathFnmatchTests.swift

Source: PathFnmatchTests.swift Github

copy
1//
2//  PathFnmatchTests.swift
3//  MockingbirdTests
4//
5//  Created by Andrew Chang on 10/29/19.
6//
7
8import XCTest
9import PathKit
10@testable import MockingbirdGenerator
11
12class PathFnmatchTests: XCTestCase {
13  
14  // MARK: - Exact
15
16  func testFnmatch_matchesExactFile() {
17    let path = Path("/foo/bar.txt")
18    XCTAssertTrue(path.matches(pattern: "/foo/bar.txt", isDirectory: false))
19  }
20
21  func testFnmatch_matchesExactDirectory_noTrailingSlash() {
22    let path = Path("/foo/bar")
23    XCTAssertTrue(path.matches(pattern: "/foo/bar/", isDirectory: true))
24  }
25  
26  func testFnmatch_matchesExactDirectory_withTrailingSlash() {
27    let path = Path("/foo/bar/")
28    XCTAssertTrue(path.matches(pattern: "/foo/bar/", isDirectory: true))
29  }
30  
31  func testFnmatch_matchesExactDirectory_rootDirectory() {
32    let path = Path("/")
33    XCTAssertTrue(path.matches(pattern: "/", isDirectory: true))
34  }
35  
36  // MARK: - Relative
37  
38  func testFnmatch_matchesRelativeFile() {
39    let path = Path("./foo/bar.txt")
40    XCTAssertTrue(path.matches(pattern: "./foo/bar.txt", isDirectory: false))
41  }
42  
43  func testFnmatch_matchesRelativeDirectory_noTrailingSlash() {
44    let path = Path("./foo/bar")
45    XCTAssertTrue(path.matches(pattern: "./foo/bar/", isDirectory: true))
46  }
47  
48  func testFnmatch_matchesRelativeDirectory_withTrailingSlash() {
49    let path = Path("./foo/bar/")
50    XCTAssertTrue(path.matches(pattern: "./foo/bar/", isDirectory: true))
51  }
52  
53  // MARK: - Wildcard
54  
55  func testFnmatch_matchesWildcardFilePath() {
56    let path = Path("/foo/bar.txt")
57    XCTAssertTrue(path.matches(pattern: "/foo/*", isDirectory: false))
58  }
59  
60  func testFnmatch_matchesWildcardFileName() {
61    let path = Path("/foo/bar.txt")
62    XCTAssertTrue(path.matches(pattern: "/foo/*.txt", isDirectory: false))
63  }
64  
65  func testFnmatch_matchesWildcardFileExtension() {
66    let path = Path("/foo/bar.txt")
67    XCTAssertTrue(path.matches(pattern: "/foo/bar.*", isDirectory: false))
68  }
69  
70  func testFnmatch_matchesWildcardDirectory_withSpecificFileName() {
71    let path = Path("/foo/baz/bar.txt")
72    XCTAssertTrue(path.matches(pattern: "/foo/**/bar.txt", isDirectory: false))
73  }
74  
75  func testFnmatch_matchesWildcardDirectory_withWildcardFilePath() {
76    let path = Path("/foo/baz/bar.txt")
77    XCTAssertTrue(path.matches(pattern: "/foo/**/*", isDirectory: false))
78  }
79  
80  func testFnmatch_matchesWildcardDirectory_withWildcardFileName() {
81    let path = Path("/foo/baz/bar.txt")
82    XCTAssertTrue(path.matches(pattern: "/foo/**/*.txt", isDirectory: false))
83  }
84  
85  func testFnmatch_matchesWildcardDirectory_withWildcardFileExtension() {
86    let path = Path("/foo/baz/bar.txt")
87    XCTAssertTrue(path.matches(pattern: "/foo/**/bar.*", isDirectory: false))
88  }
89  
90  func testFnmatch_matchesWildcardDirectory() {
91    let filePath = Path("/foo/bar.txt")
92    let directoryPath = Path("/foo/bar")
93    XCTAssertTrue(filePath.matches(pattern: "/foo/**", isDirectory: false))
94    XCTAssertTrue(directoryPath.matches(pattern: "/foo/**", isDirectory: true))
95  }
96  
97  func testFnmatch_matchesDotFile_withWildcardFileName() {
98    let filePath = Path(".foo")
99    XCTAssertTrue(filePath.matches(pattern: "*foo", isDirectory: false))
100  }
101}
102
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)