gitee.com/mirrors/gauge@v1.0.6/util/uriUtils_test.go (about) 1 // Copyright 2015 ThoughtWorks, Inc. 2 3 // This file is part of Gauge. 4 5 // Gauge is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 10 // Gauge is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 15 // You should have received a copy of the GNU General Public License 16 // along with Gauge. If not, see <http://www.gnu.org/licenses/>. 17 18 package util 19 20 import ( 21 "testing" 22 ) 23 24 func TestConvertURItoWindowsFilePath(t *testing.T) { 25 uri := `file:///c%3A/Users/gauge/project/example.spec` 26 want := `c:\Users\gauge\project\example.spec` 27 got := convertURIToWindowsPath(uri) 28 if want != got { 29 t.Errorf("got : %s, want : %s", got, want) 30 } 31 } 32 33 func TestConvertURItoUnixFilePath(t *testing.T) { 34 uri := `file:///Users/gauge/project/example.spec` 35 want := `/Users/gauge/project/example.spec` 36 got := convertURIToUnixPath(uri) 37 if want != got { 38 t.Errorf("got : %s, want : %s", got, want) 39 } 40 } 41 42 func TestConvertWindowsFilePathToURI(t *testing.T) { 43 path := `c:\Users\gauge\project\example.spec` 44 want := `file:///c%3A/Users/gauge/project/example.spec` 45 got := convertWindowsPathToURI(path) 46 if want != got { 47 t.Errorf("got : %s, want : %s", got, want) 48 } 49 } 50 51 func TestConvertUnixFilePathToURI(t *testing.T) { 52 path := `/Users/gauge/project/example.spec` 53 want := `file:///Users/gauge/project/example.spec` 54 got := convertUnixPathToURI(path) 55 if want != got { 56 t.Errorf("got : %s, want : %s", got, want) 57 } 58 }