common_test.go 849 B

1234567891011121314151617181920212223242526272829303132333435
  1. package common
  2. import (
  3. "os"
  4. checker "gopkg.in/check.v1"
  5. )
  6. type CommonSuite struct{}
  7. var _ = checker.Suite(&CommonSuite{})
  8. func (s *CommonSuite) TestOS(c *checker.C) {
  9. expwin := (os.PathSeparator == '\\' && os.PathListSeparator == ';')
  10. res := IsWindows()
  11. if !expwin {
  12. c.Assert(res, checker.Equals, expwin, checker.Commentf("IsWindows is", res, "but path is", os.PathSeparator))
  13. } else {
  14. c.Assert(res, checker.Not(checker.Equals), expwin, checker.Commentf("IsWindows is", res, "but path is", os.PathSeparator))
  15. }
  16. }
  17. func (s *CommonSuite) TestWindonziePath(c *checker.C) {
  18. iswindowspath := os.PathSeparator == '\\'
  19. path := "/opt/eth/test/file.ext"
  20. res := WindonizePath(path)
  21. ressep := string(res[0])
  22. if !iswindowspath {
  23. c.Assert(ressep, checker.Equals, "/")
  24. } else {
  25. c.Assert(ressep, checker.Not(checker.Equals), "/")
  26. }
  27. }