66 "bytes"
77 "fmt"
88 "io"
9- "io/ioutil"
109 "math"
1110 "os"
1211 "path/filepath"
@@ -87,7 +86,7 @@ func TestSerializationBasic037(t *testing.T) {
8786
8887func TestSerializationToFile038 (t * testing.T ) {
8988 rb := BitmapOf (1 , 2 , 3 , 4 , 5 , 100 , 1000 )
90- fname := "myfile.bin"
89+ fname := filepath . Join ( t . TempDir (), "myfile.bin" )
9190 fout , err := os .OpenFile (fname , os .O_RDWR | os .O_CREATE | os .O_TRUNC , 0o660 )
9291 if err != nil {
9392 fmt .Fprintf (os .Stderr , "\n \n IMPORTANT: For testing file IO, the roaring library requires disk access.\n We omit some tests for now.\n \n " )
@@ -114,10 +113,7 @@ func TestSerializationToFile038(t *testing.T) {
114113 buf := bytes .NewBuffer (nil )
115114 teer := io .TeeReader (fin , buf )
116115
117- defer func () {
118- fin .Close ()
119- _ = os .Remove (fname )
120- }()
116+ defer fin .Close ()
121117
122118 _ , _ = newrb .ReadFrom (teer )
123119 assert .True (t , rb .Equals (newrb ))
@@ -276,7 +272,7 @@ func Test_tryReadFromRoaring32WithRoaring64(t *testing.T) {
276272}
277273
278274func Test_tryReadFromRoaring32WithRoaring64_File (t * testing.T ) {
279- tempDir , err := ioutil . TempDir ("./" , "testdata" )
275+ tempDir , err := os . MkdirTemp ("./" , "testdata" )
280276 if err != nil {
281277 fmt .Fprintf (os .Stderr , "\n \n IMPORTANT: For testing file IO, the roaring library requires disk access.\n We omit some tests for now.\n \n " )
282278 return
@@ -290,7 +286,7 @@ func Test_tryReadFromRoaring32WithRoaring64_File(t *testing.T) {
290286 }
291287
292288 name := filepath .Join (tempDir , "r32" )
293- if err := ioutil .WriteFile (name , bs , 0o600 ); err != nil {
289+ if err := os .WriteFile (name , bs , 0o600 ); err != nil {
294290 t .Fatal (err )
295291 }
296292 file , err := os .Open (name )
0 commit comments