~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/encoding/csv/writer_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
import (
8
8
        "bytes"
 
9
        "errors"
9
10
        "testing"
10
11
)
11
12
 
42
43
                }
43
44
        }
44
45
}
 
46
 
 
47
type errorWriter struct{}
 
48
 
 
49
func (e errorWriter) Write(b []byte) (int, error) {
 
50
        return 0, errors.New("Test")
 
51
}
 
52
 
 
53
func TestError(t *testing.T) {
 
54
        b := &bytes.Buffer{}
 
55
        f := NewWriter(b)
 
56
        f.Write([]string{"abc"})
 
57
        f.Flush()
 
58
        err := f.Error()
 
59
 
 
60
        if err != nil {
 
61
                t.Errorf("Unexpected error: %s\n", err)
 
62
        }
 
63
 
 
64
        f = NewWriter(errorWriter{})
 
65
        f.Write([]string{"abc"})
 
66
        f.Flush()
 
67
        err = f.Error()
 
68
 
 
69
        if err == nil {
 
70
                t.Error("Error should not be nil")
 
71
        }
 
72
}