mirror of https://github.com/ethereum/go-ethereum
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.3 KiB
42 lines
1.3 KiB
9 years ago
|
// Copyright 2015 The go-ethereum Authors
|
||
2 years ago
|
// This file is part of the go-ethereum library.
|
||
9 years ago
|
//
|
||
2 years ago
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||
9 years ago
|
// the Free Software Foundation, either version 3 of the License, or
|
||
|
// (at your option) any later version.
|
||
|
//
|
||
2 years ago
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||
9 years ago
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
9 years ago
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
2 years ago
|
// GNU Lesser General Public License for more details.
|
||
9 years ago
|
//
|
||
2 years ago
|
// You should have received a copy of the GNU Lesser General Public License
|
||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||
9 years ago
|
|
||
2 years ago
|
package flags
|
||
10 years ago
|
|
||
|
import (
|
||
10 years ago
|
"os"
|
||
|
"os/user"
|
||
|
"testing"
|
||
10 years ago
|
)
|
||
|
|
||
|
func TestPathExpansion(t *testing.T) {
|
||
10 years ago
|
user, _ := user.Current()
|
||
|
tests := map[string]string{
|
||
|
"/home/someuser/tmp": "/home/someuser/tmp",
|
||
|
"~/tmp": user.HomeDir + "/tmp",
|
||
9 years ago
|
"~thisOtherUser/b/": "~thisOtherUser/b",
|
||
10 years ago
|
"$DDDXXX/a/b": "/tmp/a/b",
|
||
|
"/a/b/": "/a/b",
|
||
|
}
|
||
|
os.Setenv("DDDXXX", "/tmp")
|
||
|
for test, expected := range tests {
|
||
|
got := expandPath(test)
|
||
|
if got != expected {
|
||
|
t.Errorf("test %s, got %s, expected %s\n", test, got, expected)
|
||
|
}
|
||
|
}
|
||
10 years ago
|
}
|