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

Side by Side Diff: src/pkg/image/png/reader_test.go

Issue 4357052: code review 4357052: os: New Open API. (Closed)
Patch Set: diff -r dc1d5042801a https://go.googlecode.com/hg/ Created 12 years, 12 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:
View unified diff | Download patch
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package png 5 package png
6 6
7 import ( 7 import (
8 "bufio" 8 "bufio"
9 "fmt" 9 "fmt"
10 "image" 10 "image"
(...skipping 23 matching lines...) Expand all
34 "basn6a16", 34 "basn6a16",
35 } 35 }
36 36
37 var filenamesShort = []string{ 37 var filenamesShort = []string{
38 "basn0g01", 38 "basn0g01",
39 "basn0g04-31", 39 "basn0g04-31",
40 "basn6a16", 40 "basn6a16",
41 } 41 }
42 42
43 func readPng(filename string) (image.Image, os.Error) { 43 func readPng(filename string) (image.Image, os.Error) {
44 » f, err := os.Open(filename, os.O_RDONLY, 0444) 44 » f, err := os.Open(filename)
45 if err != nil { 45 if err != nil {
46 return nil, err 46 return nil, err
47 } 47 }
48 defer f.Close() 48 defer f.Close()
49 return Decode(f) 49 return Decode(f)
50 } 50 }
51 51
52 // An approximation of the sng command-line tool. 52 // An approximation of the sng command-line tool.
53 func sng(w io.WriteCloser, filename string, png image.Image) { 53 func sng(w io.WriteCloser, filename string, png image.Image) {
54 defer w.Close() 54 defer w.Close()
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 184 }
185 continue 185 continue
186 } 186 }
187 187
188 piper, pipew := io.Pipe() 188 piper, pipew := io.Pipe()
189 pb := bufio.NewReader(piper) 189 pb := bufio.NewReader(piper)
190 go sng(pipew, fn, img) 190 go sng(pipew, fn, img)
191 defer piper.Close() 191 defer piper.Close()
192 192
193 // Read the .sng file. 193 // Read the .sng file.
194 » » sf, err := os.Open("testdata/pngsuite/"+fn+".sng", os.O_RDONLY, 0444) 194 » » sf, err := os.Open("testdata/pngsuite/" + fn + ".sng")
195 if err != nil { 195 if err != nil {
196 t.Error(fn, err) 196 t.Error(fn, err)
197 continue 197 continue
198 } 198 }
199 defer sf.Close() 199 defer sf.Close()
200 sb := bufio.NewReader(sf) 200 sb := bufio.NewReader(sf)
201 if err != nil { 201 if err != nil {
202 t.Error(fn, err) 202 t.Error(fn, err)
203 continue 203 continue
204 } 204 }
(...skipping 13 matching lines...) Expand all
218 t.Error(fn, serr) 218 t.Error(fn, serr)
219 break 219 break
220 } 220 }
221 if ps != ss { 221 if ps != ss {
222 t.Errorf("%s: Mismatch\n%sversus\n%s\n", fn, ps, ss) 222 t.Errorf("%s: Mismatch\n%sversus\n%s\n", fn, ps, ss)
223 break 223 break
224 } 224 }
225 } 225 }
226 } 226 }
227 } 227 }
OLDNEW

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