1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package rrdbinary
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestBinaryError(t *testing.T) {
assert := assert.New(t)
bad404 := []byte(`<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"`)
err := NewBinError("not an RRD file: wrong magic number", bad404, 0, 4)
assert.Equal(err.Error(), `invalid RRD: not an RRD file: wrong magic number`)
assert.Equal(fmt.Sprintf("%v", err), `invalid RRD: not an RRD file: wrong magic number`)
assert.Equal(fmt.Sprintf("%q", err), `"invalid RRD: not an RRD file: wrong magic number"`)
assert.Equal(fmt.Sprintf("%+v", err), `invalid RRD: not an RRD file: wrong magic number
at byte 0:
ascii: < ! D O
hex : 3c 21 44 4f
`)
badShort := []byte{'R'}
err = NewBinError("not an RRD file: wrong magic number", badShort, 0, 4)
assert.Equal(err.Error(), `invalid RRD: not an RRD file: wrong magic number`)
assert.Equal(fmt.Sprintf("%v", err), `invalid RRD: not an RRD file: wrong magic number`)
assert.Equal(fmt.Sprintf("%q", err), `"invalid RRD: not an RRD file: wrong magic number"`)
assert.Equal(fmt.Sprintf("%+v", err), `invalid RRD: not an RRD file: wrong magic number
at byte 0:
ascii: R <EOF>
hex : 52 <EOF>
`)
}
|