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

Delta Between Two Patch Sets: bmp/reader_test.go

Issue 5601054: code review 5601054: go.image/{bmp,tiff}: move tiff/testdata to testdata. (Closed)
Left Patch Set: Created 13 years, 2 months ago
Right Patch Set: diff -r 726a48eb7716 https://code.google.com/p/go.image Created 13 years, 2 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 | « no previous file | testdata/bw-deflate.tiff » ('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 bmp
6
7 import (
8 "image"
9 "os"
10 "testing"
11
12 _ "image/png"
13 )
14
15 const testdataDir = "../testdata/"
16
17 func compare(t *testing.T, img0, img1 image.Image) {
18 b := img1.Bounds()
19 if !b.Eq(img0.Bounds()) {
20 t.Fatalf("wrong image size: want %s, got %s", img0.Bounds(), b)
21 }
22 for y := b.Min.Y; y < b.Max.Y; y++ {
23 for x := b.Min.X; x < b.Max.X; x++ {
24 c0 := img0.At(x, y)
25 c1 := img1.At(x, y)
26 r0, g0, b0, a0 := c0.RGBA()
27 r1, g1, b1, a1 := c1.RGBA()
28 if r0 != r1 || g0 != g1 || b0 != b1 || a0 != a1 {
29 t.Fatalf("pixel at (%d, %d) has wrong color: wan t %v, got %v", x, y, c0, c1)
30 }
31 }
32 }
33 }
34
35 // TestDecode tests that decoding a PNG image and a BMP image result in the
36 // same pixel data.
37 func TestDecode(t *testing.T) {
38 f0, err := os.Open(testdataDir + "video-001.png")
39 if err != nil {
40 t.Fatal(err)
41 }
42 defer f0.Close()
43 img0, _, err := image.Decode(f0)
44 if err != nil {
45 t.Fatal(err)
46 }
47
48 f1, err := os.Open(testdataDir + "video-001.bmp")
49 if err != nil {
50 t.Fatal(err)
51 }
52 defer f1.Close()
53 img1, _, err := image.Decode(f1)
54 if err != nil {
55 t.Fatal(err)
56 }
57
58 compare(t, img0, img1)
59 }
LEFTRIGHT

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