@@ -9,27 +9,32 @@ package os_test
9
9
import (
10
10
. "os"
11
11
"path/filepath"
12
+ "runtime"
12
13
"testing"
13
14
)
14
15
15
16
func TestTruncate (t * testing.T ) {
17
+ if runtime .GOOS == "windows" {
18
+ t .Skip ()
19
+ }
20
+
16
21
tmpDir := t .TempDir ()
17
- file := filepath .Join (tmpDir , "truncate_0x100 " )
22
+ file := filepath .Join (tmpDir , "truncate_test " )
18
23
19
24
fd , err := Create (file )
20
25
if err != nil {
21
- t .Fatalf ("create %q: %s " , file , err )
26
+ t .Fatalf ("create %q: got %v, want nil " , file , err )
22
27
}
23
28
24
29
// truncate up to 0x100
25
30
if err := fd .Truncate (0x100 ); err != nil {
26
- t .Fatalf ("truncate %q: %s " , file , err )
31
+ t .Fatalf ("truncate %q: got %v, want nil " , file , err )
27
32
}
28
33
29
34
// check if size is 0x100
30
35
fi , err := Stat (file )
31
36
if err != nil {
32
- t .Fatalf ("stat %q: %s " , file , err )
37
+ t .Fatalf ("stat %q: got %v, want nil " , file , err )
33
38
}
34
39
35
40
if fi .Size () != 0x100 {
@@ -38,13 +43,13 @@ func TestTruncate(t *testing.T) {
38
43
39
44
// truncate down to 0x80
40
45
if err := fd .Truncate (0x80 ); err != nil {
41
- t .Fatalf ("truncate %q: %s " , file , err )
46
+ t .Fatalf ("truncate %q: got %v, want nil " , file , err )
42
47
}
43
48
44
49
// check if size is 0x80
45
50
fi , err = Stat (file )
46
51
if err != nil {
47
- t .Fatalf ("stat %q: %s " , file , err )
52
+ t .Fatalf ("stat %q: got %v, want nil " , file , err )
48
53
}
49
54
50
55
if fi .Size () != 0x80 {
0 commit comments