Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1226)

Delta Between Two Patch Sets: src/pkg/syscall/syscall_windows_test.go

Issue 6261053: code review 6261053: syscall: correct Win32finddata definition (Closed)
Left Patch Set: Created 11 years, 10 months ago
Right Patch Set: diff -r a2cb3130bd86 https://go.googlecode.com/hg/ Created 11 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/syscall/syscall_windows.go ('k') | src/pkg/syscall/zsyscall_windows_386.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package syscall_test
6
7 import (
8 "io/ioutil"
9 "os"
10 "path/filepath"
11 "syscall"
12 "testing"
13 )
14
15 func TestWin32finddata(t *testing.T) {
16 dir, err := ioutil.TempDir("", "go-build")
17 if err != nil {
18 t.Fatalf("failed to create temp directory: %v", err)
19 }
20 defer os.RemoveAll(dir)
21
22 path := filepath.Join(dir, "long_name.and_extension")
23 f, err := os.Create(path)
24 if err != nil {
25 t.Fatalf("failed to create %v: %v", path, err)
26 }
27 f.Close()
28
29 type X struct {
30 fd syscall.Win32finddata1
31 got byte
32 pad [10]byte // to protect ourselves
33
34 }
35 var want byte = 2 // it is unlikely to have this character in the filena me
36 x := X{got: want}
37
38 h, err := syscall.FindFirstFile1(syscall.StringToUTF16Ptr(path), &(x.fd) )
39 if err != nil {
40 t.Fatalf("FindFirstFile failed: %v", err)
41 }
42 err = syscall.FindClose(h)
43 if err != nil {
44 t.Fatalf("FindClose failed: %v", err)
45 }
46
47 if x.got != want {
48 t.Fatalf("memory corruption: want=%d got=%d", want, x.got)
49 }
50 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b