path_test.go 863 B

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