func (s *memLocationTest) TestNewLocation() {
	otherFile, nerr := s.fileSystem.NewFile("", "/foo/foo.txt")
	s.NoError(nerr, "unexpected error creating a new file")
	fileLocation := otherFile.Location()
	subDir, lerr := fileLocation.NewLocation("other/")
	s.NoError(lerr, "unexpected error creating a new location")
	s.Equal("/foo/other/", subDir.Path())
	relDir, lerr2 := subDir.NewLocation("../../bar/")
	s.NoError(lerr2, "unexpected error creating a new location")
	s.Equal("/bar/", relDir.Path(), "relative dot path works")
}
TestNewLocation ensures that we can create new locations, even with relative dot paths
package mem
import (
	"path"
	"regexp"
	"testing"
	"github.com/stretchr/testify/suite"
	"github.com/c2fo/vfs/v6"
)
type memLocationTest struct {
	suite.Suite
	testFile   vfs.File
	fileSystem *FileSystem
}
func (s *memLocationTest) SetupTest() {
	fs := NewFileSystem()
	file, nerr := fs.NewFile("", "/test_files/test.txt")
	s.NoError(nerr, "file creation was not successful so it does not exist")
	s.testFile = file.(*File)
	s.fileSystem = fs
	s.NoError(s.testFile.Touch(), "unexpected error touching file")
}
func (s *memLocationTest) TestFSName() {
	s.Equal(s.testFile.Location().FileSystem().Name(), "In-Memory Filesystem")
	s.Equal(s.testFile.Location().FileSystem().Scheme(), "mem")
}
func (s *memLocationTest) TestList() {
	expected := []string{"test.txt"}
	actual, _ := s.testFile.Location().List()
	s.Equal(expected, actual)
}
func (s *memLocationTest) TestList_NonExistentDirectory() {
	location, err := s.testFile.Location().NewLocation("not/a/directory/")
	s.Nil(err, "error isn't expected")
	exists, err := location.Exists()
	s.Nil(err, "error isn't expected")
	s.True(exists, "location should return true for Exists")
	contents, err := location.List()
	s.Nil(err, "error isn't expected")
	s.Equal(0, len(contents), "list should return empty slice for non-existent directory")
	prefixContents, err := location.ListByPrefix("anything")
	s.Nil(err, "error isn't expected")
	s.Equal(0, len(prefixContents), "ListByPrefix should return empty slice for non-existent directory")
	regex := regexp.MustCompile("-+")
	regexContents, err := location.ListByRegex(regex)
	s.Nil(err, "error isn't expected")
	s.Equal(0, len(regexContents), "ListByRegex should return empty slice for non-existent directory")
}
func (s *memLocationTest) TestListByPrefix() {
	f1, nerr := s.fileSystem.NewFile("", "/foo.txt")
	s.NoError(nerr, "unexpected error creating a new file")
	s.NoError(f1.Touch(), "unexpected error touching file")
	f2, nerr := s.fileSystem.NewFile("", "/home/test_files/subdir/file1.txt")
	s.NoError(nerr, "unexpected error creating a new file")
	s.NoError(f2.Touch(), "unexpected error touching file")
	f3, nerr := s.fileSystem.NewFile("", "/home/test_files/subdir/file2.txt")
	s.NoError(nerr, "unexpected error creating a new file")
	s.NoError(f3.Touch(), "unexpected error touching file")
	f4, nerr := s.fileSystem.NewFile("", "/home/directories/test/mat.txt")
	s.NoError(nerr, "unexpected error creating a new file")
	s.NoError(f4.Touch(), "unexpected error touching file")
	f5, nerr := s.fileSystem.NewFile("", "/test/files/car.txt")
	s.NoError(nerr, "unexpected error creating a new file")
	s.NoError(f5.Touch(), "unexpected error touching file")
	loc, lerr := s.fileSystem.NewLocation("", "/home/test_files/subdir/")
	s.NoError(lerr, "unexpected error creating a location")
	nameSlice, lerr := loc.ListByPrefix("f")
	s.NoError(lerr, "unexpected error obtaining list by prefix")
	expectedSlice := []string{"file1.txt", "file2.txt"}
	s.Equal(expectedSlice, nameSlice)
	emptySlice, err := s.testFile.Location().ListByPrefix("m")
	s.NoError(err, "unexpected error retrieving files by prefix")
	s.Equal(make([]string, 0), emptySlice)  
}
func (s *memLocationTest) TestListByRegex() {
	newFile, nerr := s.fileSystem.NewFile("", "/test_files/test.txt")
	s.NoError(nerr, "unexpected error creating a new file")
	s.NoError(newFile.Touch(), "unexpected error touching file")
	expected := []string{"test.txt"}
	regex := regexp.MustCompile("[est]+")
	actual, err := newFile.Location().ListByRegex(regex)
	s.NoError(err, "unexpected error listing by regEx")
	s.Equal(expected, actual)
	err = newFile.Location().ChangeDir("../")
	s.NoError(err, "unexpected error changing directories")
	regex2 := regexp.MustCompile("test.txt")
	actual2, err := newFile.Location().ListByRegex(regex2)
	s.NoError(err, "unexpected error listing by regEx")
	s.Equal(expected, actual2)
}
func (s *memLocationTest) TestExists() {
	otherFile, nerr := s.fileSystem.NewFile("", "/foo/foo.txt")
	s.NoError(nerr, "unexpected error creating a new file")
	s.True(s.testFile.Location().Exists())
	s.True(otherFile.Location().Exists())
}