@@ -19,7 +19,7 @@ enum DeepLinkMock: Equatable {
1919 @URLPath ( " /posts/{postId}/comments/{commentId} " )
2020 case postComment( postId: String , commentId: String )
2121
22- @URLPath ( " /setting/{number} " )
22+ @URLPath ( " /setting/phone/ {number} " )
2323 case setting( number: Int )
2424
2525 @URLPath ( " /int/{int} " )
@@ -104,8 +104,8 @@ struct URLPatternExampleTests {
104104
105105 // MARK: - Setting Tests
106106 @Test ( " Valid Setting URLPatterns " , arguments: [
107- " https://domain.com/setting/42 " ,
108- " /setting/42 "
107+ " https://domain.com/setting/phone/ 42 " ,
108+ " /setting/phone/ 42 "
109109 ] )
110110 func parseSetting_success( urlString: String ) async throws {
111111 let url = try #require( URL ( string: urlString) )
@@ -114,9 +114,9 @@ struct URLPatternExampleTests {
114114 }
115115
116116 @Test ( " Invalid Setting URLPatterns " , arguments: [
117- " https://domain.com/setting/abc " ,
118- " /setting/12.34 " ,
119- " /setting/ "
117+ " https://domain.com/setting/abc/42 " ,
118+ " /setting/phone/ 12.34 " ,
119+ " /setting/phone "
120120 ] )
121121 func parseSetting_failure( urlString: String ) async throws {
122122 let url = try #require( URL ( string: urlString) )
@@ -214,4 +214,77 @@ struct URLPatternExampleTests {
214214 let deepLink = DeepLinkMock ( url: url)
215215 #expect( deepLink == nil )
216216 }
217+
218+ // MARK: - Unicode Tests
219+ @Test ( " Valid Unicodes " , arguments: [
220+ " 안녕하세요 " ,
221+ " こんにちは " ,
222+ " ☺️👍 "
223+ ] )
224+ func paresPost_success_with_unicode( value: String ) async throws {
225+ let url = try #require( URL ( string: " /posts/ \( value) " ) )
226+ let deepLink = DeepLinkMock ( url: url)
227+ #expect( deepLink == . post( postId: value) )
228+ }
229+
230+ // MARK: - Unicode Tests
231+ @URLPattern
232+ enum PriorityTest : Equatable {
233+ @URLPath ( " /{a}/{b} " )
234+ case all( a: String , b: String )
235+
236+ @URLPath ( " /post/{postId} " )
237+ case post( postId: Int )
238+ }
239+
240+ @Test func checkPriorityCases( ) async throws {
241+ let url = try #require( URL ( string: " /post/1 " ) )
242+ #expect( PriorityTest ( url: url) == . all( a: " post " , b: " 1 " ) )
243+ }
244+
245+ @URLPattern
246+ enum ScopeTest {
247+ @URLPath ( " / " )
248+ case zero
249+
250+ @URLPath ( " /{a} " )
251+ case one( a: String )
252+
253+ @URLPath ( " /{a}/{b} " )
254+ case two( a: String , b: String )
255+
256+ @URLPath ( " /{a}/{b}/{c} " )
257+ case three( a: String , b: String , c: String )
258+
259+ @URLPath ( " /{a}/{b}/{c}/{d} " )
260+ case four( a: String , b: String , c: String , d: String )
261+
262+ @URLPath ( " /{a}/{b}/{c}/{d}/{e} " )
263+ case five( a: String , b: String , c: String , d: String , e: String )
264+
265+ @URLPath ( " /{a}/{b}/{c}/{d}/{e}/{f} " )
266+ case six( a: String , b: String , c: String , d: String , e: String , f: String )
267+
268+ @URLPath ( " /{a}/{b}/{c}/{d}/{e}/{f}/{g} " )
269+ case seven( a: String , b: String , c: String , d: String , e: String , f: String , g: String )
270+
271+ @URLPath ( " /{a}/{b}/{c}/{d}/{e}/{f}/{g}/{h} " )
272+ case eight( a: String , b: String , c: String , d: String , e: String , f: String , g: String , h: String )
273+
274+ @URLPath ( " /{a}/{b}/{c}/{d}/{e}/{f}/{g}/{h}/{i} " )
275+ case nine( a: String , b: String , c: String , d: String , e: String , f: String , g: String , h: String , i: String )
276+
277+ @URLPath ( " /{a}/{b}/{c}/{d}/{e}/{f}/{g}/{h}/{i}/{j} " )
278+ case ten( a: String , b: String , c: String , d: String , e: String , f: String , g: String , h: String , i: String , j: String )
279+ }
280+ @Test ( " Test scope " , arguments: Array ( 0 ... 20 ) )
281+ func checkScope( num: Int ) async throws {
282+ let url = try #require( URL ( string: " / " + ( 0 ..< num) . map { String ( $0) } . joined ( separator: " / " ) ) )
283+
284+ if num > 10 {
285+ #expect( ScopeTest ( url: url) == nil )
286+ } else {
287+ #expect( ScopeTest ( url: url) != nil )
288+ }
289+ }
217290}
0 commit comments