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

Side by Side Diff: src/cmd/gofmt/gofmt_test.go

Issue 7038051: code review 7038051: src: Use bytes.Equal instead of bytes.Compare where pos... (Closed)
Patch Set: diff -r be6ca9f6bfe8 https://code.google.com/p/go Created 11 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:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/cmd/gofmt/long_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 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 main 5 package main
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "io/ioutil" 9 "io/ioutil"
10 "path/filepath" 10 "path/filepath"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 t.Error(err) 49 t.Error(err)
50 return 50 return
51 } 51 }
52 52
53 expected, err := ioutil.ReadFile(out) 53 expected, err := ioutil.ReadFile(out)
54 if err != nil { 54 if err != nil {
55 t.Error(err) 55 t.Error(err)
56 return 56 return
57 } 57 }
58 58
59 » if got := buf.Bytes(); bytes.Compare(got, expected) != 0 { 59 » if got := buf.Bytes(); !bytes.Equal(got, expected) {
60 t.Errorf("(gofmt %s) != %s (see %s.gofmt)", in, out, in) 60 t.Errorf("(gofmt %s) != %s (see %s.gofmt)", in, out, in)
61 d, err := diff(expected, got) 61 d, err := diff(expected, got)
62 if err == nil { 62 if err == nil {
63 t.Errorf("%s", d) 63 t.Errorf("%s", d)
64 } 64 }
65 ioutil.WriteFile(in+".gofmt", got, 0666) 65 ioutil.WriteFile(in+".gofmt", got, 0666)
66 } 66 }
67 } 67 }
68 68
69 var tests = []struct { 69 var tests = []struct {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 122
123 data, err = ioutil.ReadFile(golden) 123 data, err = ioutil.ReadFile(golden)
124 if err != nil { 124 if err != nil {
125 t.Error(err) 125 t.Error(err)
126 } 126 }
127 if bytes.Index(data, []byte("\r")) >= 0 { 127 if bytes.Index(data, []byte("\r")) >= 0 {
128 t.Errorf("%s contains CR's", golden) 128 t.Errorf("%s contains CR's", golden)
129 } 129 }
130 } 130 }
OLDNEW
« no previous file with comments | « no previous file | src/cmd/gofmt/long_test.go » ('j') | no next file with comments »

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