mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
go/token: add TestRemovedFileFileReturnsNil test
While debugging test issue in the previous CL i noted that we don't have a proper test for RemoveFile. Change-Id: I6a6a6964426ed3cf6725a58ec377686c2900c626 Reviewed-on: https://go-review.googlesource.com/c/go/+/705757 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com>
This commit is contained in:
parent
902dc27ae9
commit
74cc463f9e
1 changed files with 22 additions and 0 deletions
|
|
@ -621,3 +621,25 @@ func TestRemoveFileRace(t *testing.T) {
|
|||
start <- struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemovedFileFileReturnsNil(t *testing.T) {
|
||||
fset := NewFileSet()
|
||||
|
||||
// Create bunch of files.
|
||||
var files []*File
|
||||
for i := range 1000 {
|
||||
f := fset.AddFile("f", -1, (i+1)*100)
|
||||
files = append(files, f)
|
||||
}
|
||||
|
||||
rand.Shuffle(len(files), func(i, j int) {
|
||||
files[i], files[j] = files[j], files[i]
|
||||
})
|
||||
|
||||
for _, f := range files {
|
||||
fset.RemoveFile(f)
|
||||
if got := fset.File(Pos(f.Base()) + 10); got != nil {
|
||||
t.Fatalf("file was not removed correctly; got file with base: %v", got.Base())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue