@@ -443,7 +443,6 @@ static dot_dot_static: &'static [u8] = b"..";
443
443
mod tests {
444
444
use prelude:: * ;
445
445
use super :: * ;
446
- use mem;
447
446
use str;
448
447
use str:: StrPrelude ;
449
448
@@ -601,10 +600,8 @@ mod tests {
601
600
macro_rules! t(
602
601
( s: $path: expr, $op: ident, $exp: expr) => (
603
602
{
604
- unsafe {
605
- let path = Path :: new( $path) ;
606
- assert!( path. $op( ) == mem:: transmute( ( $exp) . as_bytes( ) ) ) ;
607
- }
603
+ let path = Path :: new( $path) ;
604
+ assert!( path. $op( ) == ( $exp) . as_bytes( ) ) ;
608
605
}
609
606
) ;
610
607
( s: $path: expr, $op: ident, $exp: expr, opt) => (
@@ -616,11 +613,9 @@ mod tests {
616
613
) ;
617
614
( v: $path: expr, $op: ident, $exp: expr) => (
618
615
{
619
- unsafe {
620
- let arg = $path;
621
- let path = Path :: new( arg) ;
622
- assert!( path. $op( ) == mem:: transmute( $exp) ) ;
623
- }
616
+ let arg = $path;
617
+ let path = Path :: new( arg) ;
618
+ assert!( path. $op( ) == $exp) ;
624
619
}
625
620
) ;
626
621
)
@@ -668,9 +663,8 @@ mod tests {
668
663
t ! ( v: b"hi/there.txt" , extension, Some ( b"txt" ) ) ;
669
664
t ! ( v: b"hi/there\x80 .txt" , extension, Some ( b"txt" ) ) ;
670
665
t ! ( v: b"hi/there.t\x80 xt" , extension, Some ( b"t\x80 xt" ) ) ;
671
- let no: Option < & ' static [ u8 ] > = None ;
672
- t ! ( v: b"hi/there" , extension, no) ;
673
- t ! ( v: b"hi/there\x80 " , extension, no) ;
666
+ t ! ( v: b"hi/there" , extension, None ) ;
667
+ t ! ( v: b"hi/there\x80 " , extension, None ) ;
674
668
t ! ( s: "hi/there.txt" , extension, Some ( "txt" ) , opt) ;
675
669
t ! ( s: "hi/there" , extension, None , opt) ;
676
670
t ! ( s: "there.txt" , extension, Some ( "txt" ) , opt) ;
@@ -959,62 +953,57 @@ mod tests {
959
953
macro_rules! t(
960
954
( s: $path: expr, $filename: expr, $dirname: expr, $filestem: expr, $ext: expr) => (
961
955
{
962
- unsafe {
963
- let path = $path;
964
- let filename = $filename;
965
- assert!( path. filename_str( ) == filename,
966
- "{}.filename_str(): Expected `{}`, found {}" ,
967
- path. as_str( ) . unwrap( ) , filename, path. filename_str( ) ) ;
968
- let dirname = $dirname;
969
- assert!( path. dirname_str( ) == dirname,
970
- "`{}`.dirname_str(): Expected `{}`, found `{}`" ,
971
- path. as_str( ) . unwrap( ) , dirname, path. dirname_str( ) ) ;
972
- let filestem = $filestem;
973
- assert!( path. filestem_str( ) == filestem,
974
- "`{}`.filestem_str(): Expected `{}`, found `{}`" ,
975
- path. as_str( ) . unwrap( ) , filestem, path. filestem_str( ) ) ;
976
- let ext = $ext;
977
- assert!( path. extension_str( ) == mem:: transmute( ext) ,
978
- "`{}`.extension_str(): Expected `{}`, found `{}`" ,
979
- path. as_str( ) . unwrap( ) , ext, path. extension_str( ) ) ;
980
- }
956
+ let path = $path;
957
+ let filename = $filename;
958
+ assert!( path. filename_str( ) == filename,
959
+ "{}.filename_str(): Expected `{}`, found {}" ,
960
+ path. as_str( ) . unwrap( ) , filename, path. filename_str( ) ) ;
961
+ let dirname = $dirname;
962
+ assert!( path. dirname_str( ) == dirname,
963
+ "`{}`.dirname_str(): Expected `{}`, found `{}`" ,
964
+ path. as_str( ) . unwrap( ) , dirname, path. dirname_str( ) ) ;
965
+ let filestem = $filestem;
966
+ assert!( path. filestem_str( ) == filestem,
967
+ "`{}`.filestem_str(): Expected `{}`, found `{}`" ,
968
+ path. as_str( ) . unwrap( ) , filestem, path. filestem_str( ) ) ;
969
+ let ext = $ext;
970
+ assert!( path. extension_str( ) == ext,
971
+ "`{}`.extension_str(): Expected `{}`, found `{}`" ,
972
+ path. as_str( ) . unwrap( ) , ext, path. extension_str( ) ) ;
981
973
}
982
974
) ;
983
975
( v: $path: expr, $filename: expr, $dirname: expr, $filestem: expr, $ext: expr) => (
984
976
{
985
- unsafe {
986
- let path = $path;
987
- assert!( path. filename( ) == mem:: transmute( $filename) ) ;
988
- assert!( path. dirname( ) == mem:: transmute( $dirname) ) ;
989
- assert!( path. filestem( ) == mem:: transmute( $filestem) ) ;
990
- assert!( path. extension( ) == mem:: transmute( $ext) ) ;
991
- }
977
+ let path = $path;
978
+ assert!( path. filename( ) == $filename) ;
979
+ assert!( path. dirname( ) == $dirname) ;
980
+ assert!( path. filestem( ) == $filestem) ;
981
+ assert!( path. extension( ) == $ext) ;
992
982
}
993
983
)
994
984
)
995
985
996
- let no: Option < & ' static str > = None ;
997
- t ! ( v: Path :: new( b"a/b/c" ) , Some ( b"c" ) , b"a/b" , Some ( b"c" ) , no) ;
998
- t ! ( v: Path :: new( b"a/b/\xFF " ) , Some ( b"\xFF " ) , b"a/b" , Some ( b"\xFF " ) , no) ;
986
+ t ! ( v: Path :: new( b"a/b/c" ) , Some ( b"c" ) , b"a/b" , Some ( b"c" ) , None ) ;
987
+ t ! ( v: Path :: new( b"a/b/\xFF " ) , Some ( b"\xFF " ) , b"a/b" , Some ( b"\xFF " ) , None ) ;
999
988
t ! ( v: Path :: new( b"hi/there.\xFF " ) , Some ( b"there.\xFF " ) , b"hi" ,
1000
989
Some ( b"there" ) , Some ( b"\xFF " ) ) ;
1001
- t ! ( s: Path :: new( "a/b/c" ) , Some ( "c" ) , Some ( "a/b" ) , Some ( "c" ) , no ) ;
1002
- t ! ( s: Path :: new( "." ) , None , Some ( "." ) , None , no ) ;
1003
- t ! ( s: Path :: new( "/" ) , None , Some ( "/" ) , None , no ) ;
1004
- t ! ( s: Path :: new( ".." ) , None , Some ( ".." ) , None , no ) ;
1005
- t ! ( s: Path :: new( "../.." ) , None , Some ( "../.." ) , None , no ) ;
990
+ t ! ( s: Path :: new( "a/b/c" ) , Some ( "c" ) , Some ( "a/b" ) , Some ( "c" ) , None ) ;
991
+ t ! ( s: Path :: new( "." ) , None , Some ( "." ) , None , None ) ;
992
+ t ! ( s: Path :: new( "/" ) , None , Some ( "/" ) , None , None ) ;
993
+ t ! ( s: Path :: new( ".." ) , None , Some ( ".." ) , None , None ) ;
994
+ t ! ( s: Path :: new( "../.." ) , None , Some ( "../.." ) , None , None ) ;
1006
995
t ! ( s: Path :: new( "hi/there.txt" ) , Some ( "there.txt" ) , Some ( "hi" ) ,
1007
996
Some ( "there" ) , Some ( "txt" ) ) ;
1008
- t ! ( s: Path :: new( "hi/there" ) , Some ( "there" ) , Some ( "hi" ) , Some ( "there" ) , no ) ;
997
+ t ! ( s: Path :: new( "hi/there" ) , Some ( "there" ) , Some ( "hi" ) , Some ( "there" ) , None ) ;
1009
998
t ! ( s: Path :: new( "hi/there." ) , Some ( "there." ) , Some ( "hi" ) ,
1010
999
Some ( "there" ) , Some ( "" ) ) ;
1011
- t ! ( s: Path :: new( "hi/.there" ) , Some ( ".there" ) , Some ( "hi" ) , Some ( ".there" ) , no ) ;
1000
+ t ! ( s: Path :: new( "hi/.there" ) , Some ( ".there" ) , Some ( "hi" ) , Some ( ".there" ) , None ) ;
1012
1001
t ! ( s: Path :: new( "hi/..there" ) , Some ( "..there" ) , Some ( "hi" ) ,
1013
1002
Some ( "." ) , Some ( "there" ) ) ;
1014
- t ! ( s: Path :: new( b"a/b/\xFF " ) , None , Some ( "a/b" ) , None , no ) ;
1003
+ t ! ( s: Path :: new( b"a/b/\xFF " ) , None , Some ( "a/b" ) , None , None ) ;
1015
1004
t ! ( s: Path :: new( b"a/b/\xFF .txt" ) , None , Some ( "a/b" ) , None , Some ( "txt" ) ) ;
1016
- t ! ( s: Path :: new( b"a/b/c.\x80 " ) , None , Some ( "a/b" ) , Some ( "c" ) , no ) ;
1017
- t ! ( s: Path :: new( b"\xFF /b" ) , Some ( "b" ) , None , Some ( "b" ) , no ) ;
1005
+ t ! ( s: Path :: new( b"a/b/c.\x80 " ) , None , Some ( "a/b" ) , Some ( "c" ) , None ) ;
1006
+ t ! ( s: Path :: new( b"\xFF /b" ) , Some ( "b" ) , None , Some ( "b" ) , None ) ;
1018
1007
}
1019
1008
1020
1009
#[ test]
0 commit comments