github.com/getgauge/gauge@v1.6.9/util/uriUtils_test.go (about)

     1  /*----------------------------------------------------------------
     2   *  Copyright (c) ThoughtWorks, Inc.
     3   *  Licensed under the Apache License, Version 2.0
     4   *  See LICENSE in the project root for license information.
     5   *----------------------------------------------------------------*/
     6  
     7  package util
     8  
     9  import (
    10  	"testing"
    11  )
    12  
    13  func TestConvertURItoWindowsFilePath(t *testing.T) {
    14  	uri := `file:///c%3A/Users/gauge/project/example.spec`
    15  	want := `c:\Users\gauge\project\example.spec`
    16  	got := convertURIToWindowsPath(uri)
    17  	if want != got {
    18  		t.Errorf("got : %s, want : %s", got, want)
    19  	}
    20  }
    21  
    22  func TestConvertURItoUnixFilePath(t *testing.T) {
    23  	uri := `file:///Users/gauge/project/example.spec`
    24  	want := `/Users/gauge/project/example.spec`
    25  	got := convertURIToUnixPath(uri)
    26  	if want != got {
    27  		t.Errorf("got : %s, want : %s", got, want)
    28  	}
    29  }
    30  
    31  func TestConvertWindowsFilePathToURI(t *testing.T) {
    32  	path := `c:\Users\gauge\project\example.spec`
    33  	want := `file:///c%3A/Users/gauge/project/example.spec`
    34  	got := convertWindowsPathToURI(path)
    35  	if want != got {
    36  		t.Errorf("got : %s, want : %s", got, want)
    37  	}
    38  }
    39  
    40  func TestConvertUnixFilePathToURI(t *testing.T) {
    41  	path := `/Users/gauge/project/example.spec`
    42  	want := `file:///Users/gauge/project/example.spec`
    43  	got := convertUnixPathToURI(path)
    44  	if want != got {
    45  		t.Errorf("got : %s, want : %s", got, want)
    46  	}
    47  }