github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/Unknwon/com/path_test.go (about) 1 // Copyright 2013 com authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 // not use this file except in compliance with the License. You may obtain 5 // a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations 13 // under the License. 14 15 package com 16 17 import ( 18 "os" 19 "runtime" 20 "testing" 21 ) 22 23 func TestGetGOPATHs(t *testing.T) { 24 var gpsR []string 25 26 if runtime.GOOS != "windows" { 27 gpsR = []string{"path/to/gopath1", "path/to/gopath2", "path/to/gopath3"} 28 os.Setenv("GOPATH", "path/to/gopath1:path/to/gopath2:path/to/gopath3") 29 } else { 30 gpsR = []string{"path/to/gopath1", "path/to/gopath2", "path/to/gopath3"} 31 os.Setenv("GOPATH", "path\\to\\gopath1;path\\to\\gopath2;path\\to\\gopath3") 32 } 33 34 gps := GetGOPATHs() 35 if !CompareSliceStr(gps, gpsR) { 36 t.Errorf("GetGOPATHs:\n Expect => %s\n Got => %s\n", gpsR, gps) 37 } 38 } 39 40 func TestGetSrcPath(t *testing.T) { 41 42 } 43 44 func TestHomeDir(t *testing.T) { 45 _, err := HomeDir() 46 if err != nil { 47 t.Errorf("HomeDir:\n Expect => %v\n Got => %s\n", nil, err) 48 } 49 } 50 51 func BenchmarkGetGOPATHs(b *testing.B) { 52 for i := 0; i < b.N; i++ { 53 GetGOPATHs() 54 } 55 } 56 57 func BenchmarkGetSrcPath(b *testing.B) { 58 for i := 0; i < b.N; i++ { 59 GetSrcPath("github.com/insionng/yougam/libraries/Unknwon/com") 60 } 61 } 62 63 func BenchmarkHomeDir(b *testing.B) { 64 for i := 0; i < b.N; i++ { 65 HomeDir() 66 } 67 }