go-ethereum/common/common_test.go

36 lines
849 B
Go
Raw Normal View History

2015-03-16 11:27:38 +01:00
package common
2014-02-25 11:20:24 +01:00
import (
"os"
2014-11-16 12:08:27 -06:00
checker "gopkg.in/check.v1"
2014-02-25 11:20:24 +01:00
)
2014-11-16 12:08:27 -06:00
type CommonSuite struct{}
2014-11-16 12:08:27 -06:00
var _ = checker.Suite(&CommonSuite{})
func (s *CommonSuite) TestOS(c *checker.C) {
expwin := (os.PathSeparator == '\\' && os.PathListSeparator == ';')
res := IsWindows()
2014-11-16 12:08:27 -06:00
if !expwin {
c.Assert(res, checker.Equals, expwin, checker.Commentf("IsWindows is", res, "but path is", os.PathSeparator))
} else {
c.Assert(res, checker.Not(checker.Equals), expwin, checker.Commentf("IsWindows is", res, "but path is", os.PathSeparator))
}
}
2014-11-16 12:08:27 -06:00
func (s *CommonSuite) TestWindonziePath(c *checker.C) {
iswindowspath := os.PathSeparator == '\\'
path := "/opt/eth/test/file.ext"
res := WindonizePath(path)
2014-11-16 12:08:27 -06:00
ressep := string(res[0])
2014-11-16 12:08:27 -06:00
if !iswindowspath {
c.Assert(ressep, checker.Equals, "/")
} else {
c.Assert(ressep, checker.Not(checker.Equals), "/")
}
}