@@ -490,6 +490,7 @@ impl RawMessage {
490
490
#[ cfg( test) ]
491
491
mod test {
492
492
use super :: * ;
493
+ use url:: Url ;
493
494
494
495
fn get_default_params ( ) -> InitializeParams {
495
496
InitializeParams {
@@ -506,24 +507,35 @@ mod test {
506
507
}
507
508
}
508
509
510
+ fn make_platform_path ( path : & ' static str ) -> PathBuf {
511
+ if cfg ! ( windows) {
512
+ PathBuf :: from ( format ! ( "C:/{}" , path) )
513
+ } else {
514
+ PathBuf :: from ( format ! ( "/{}" , path) )
515
+ }
516
+ }
517
+
509
518
#[ test]
510
519
fn test_use_root_uri ( ) {
511
520
let mut params = get_default_params ( ) ;
512
521
513
- params. root_path = Some ( String :: from ( "/path/a" ) ) ;
514
- params. root_uri = Some ( :: url:: Url :: parse ( "file:///path/b" ) . unwrap ( ) ) ;
522
+ let root_path = make_platform_path ( "path/a" ) ;
523
+ let root_uri = make_platform_path ( "path/b" ) ;
524
+ params. root_path = Some ( root_path. to_str ( ) . unwrap ( ) . to_owned ( ) ) ;
525
+ params. root_uri = Some ( Url :: from_directory_path ( & root_uri) . unwrap ( ) ) ;
515
526
516
- assert_eq ! ( get_root_path( & params) . to_str ( ) . unwrap ( ) , "/path/b" ) ;
527
+ assert_eq ! ( get_root_path( & params) , root_uri ) ;
517
528
}
518
529
519
530
#[ test]
520
531
fn test_use_root_path ( ) {
521
532
let mut params = get_default_params ( ) ;
522
533
523
- params. root_path = Some ( String :: from ( "/path/a" ) ) ;
534
+ let root_path = make_platform_path ( "path/a" ) ;
535
+ params. root_path = Some ( root_path. to_str ( ) . unwrap ( ) . to_owned ( ) ) ;
524
536
params. root_uri = None ;
525
537
526
- assert_eq ! ( get_root_path( & params) . to_str ( ) . unwrap ( ) , "/path/a" ) ;
538
+ assert_eq ! ( get_root_path( & params) , root_path ) ;
527
539
}
528
540
529
541
#[ test]
0 commit comments