@@ -329,6 +329,50 @@ struct PathTests {
329
329
}
330
330
}
331
331
332
+ @Test (
333
+ arguments: [
334
+ ( path: " / " , expected: " / " ) ,
335
+ ( path: " /. " , expected: " / " ) ,
336
+ ( path: " /.. " , expected: " / " ) ,
337
+ ( path: " /bar/ " , expected: " /bar " ) ,
338
+ ] , [
339
+ " " ,
340
+ " " ,
341
+ " \t " ,
342
+ " \t \t " ,
343
+ " \n " ,
344
+ " \n \n " ,
345
+ " \t " ,
346
+ " \t " ,
347
+ " \n \t " ,
348
+ " \n \t " ,
349
+ ] ,
350
+ )
351
+ func absolutePathValidationWithPathContainsLeadingAndTrailingWhitespaces(
352
+ data: ( String , String ) ,
353
+ whitespaces: String ,
354
+ ) throws {
355
+ let path = data. 0
356
+ let expected = data. 1
357
+ do {
358
+ // Leading whitespaces
359
+ let actual = try AbsolutePath ( validating: " \( whitespaces) \( path) " ) . pathString
360
+ #expect( actual == expected, " Actual is not as expected. Path is: ' \( path) ' " )
361
+ }
362
+
363
+ do {
364
+ // Training whitespaces
365
+ let actual = try AbsolutePath ( validating: " \( path) \( whitespaces) " ) . pathString
366
+ #expect( actual == expected, " Actual is not as expected. Path is: ' \( path) ' " )
367
+ }
368
+
369
+ do {
370
+ // Leading and trailing whitespaces
371
+ let actual = try AbsolutePath ( validating: " \( whitespaces) \( path) \( whitespaces) " ) . pathString
372
+ #expect( actual == expected, " Actual is not as expected. Path is: ' \( path) ' " )
373
+ }
374
+ }
375
+
332
376
@Test
333
377
func comparison( ) {
334
378
#expect( AbsolutePath ( " / " ) <= AbsolutePath ( " / " ) ) ;
@@ -637,6 +681,49 @@ struct PathTests {
637
681
}
638
682
}
639
683
684
+ @Test (
685
+ arguments: [
686
+ ( path: " . " , expected: " . " ) ,
687
+ ( path: " bar/ " , expected: " bar " ) ,
688
+ ( path: " bar/baz " , expected: " bar/baz " ) ,
689
+ ] , [
690
+ " " ,
691
+ " " ,
692
+ " \t " ,
693
+ " \t \t " ,
694
+ " \n " ,
695
+ " \n \n " ,
696
+ " \t " ,
697
+ " \t " ,
698
+ " \n \t " ,
699
+ " \n \t " ,
700
+ ] ,
701
+ )
702
+ func relativePathValidationWithPathContainsLeadingAndTrailingWhitespaces(
703
+ data: ( String , String ) ,
704
+ whitespaces: String ,
705
+ ) throws {
706
+ let path = data. 0
707
+ let expected = data. 1
708
+ do {
709
+ // Leading whitespaces
710
+ let actual = try RelativePath ( validating: " \( whitespaces) \( path) " ) . pathString
711
+ #expect( actual == expected, " Actual is not as expected. Path is: ' \( path) ' " )
712
+ }
713
+
714
+ do {
715
+ // Training whitespaces
716
+ let actual = try RelativePath ( validating: " \( path) \( whitespaces) " ) . pathString
717
+ #expect( actual == expected, " Actual is not as expected. Path is: ' \( path) ' " )
718
+ }
719
+
720
+ do {
721
+ // Leading and trailing whitespaces
722
+ let actual = try RelativePath ( validating: " \( whitespaces) \( path) \( whitespaces) " ) . pathString
723
+ #expect( actual == expected, " Actual is not as expected. Path is: ' \( path) ' " )
724
+ }
725
+ }
726
+
640
727
}
641
728
642
729
@Test
0 commit comments