forked from Morganamilo/go-srcinfo
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
line_error_test.go
45 lines (33 loc) · 1.06 KB
/
line_error_test.go
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
35
36
37
38
39
40
41
42
43
44
45
package srcinfo
import (
"testing"
)
const lineNumber int = 5
const line string = "pkgbase ="
const errorStr string = "Value is empty"
func TestLineError(t *testing.T) {
err := Error(lineNumber, line, errorStr)
if err.LineNumber != lineNumber {
t.Errorf("Line number should be %d but was %d", lineNumber, err.LineNumber)
}
if err.Line != line {
t.Errorf("Line should be \"%s\" but was \"%s\"", line, err.Line)
}
if err.ErrorStr != errorStr {
t.Errorf("ErrorStr should be \"%s\" but was \"%s\"", errorStr, err.ErrorStr)
}
t.Logf("error: %#v generated message: %s", err, err.Error())
}
func TestLineErrorf(t *testing.T) {
err := Errorf(lineNumber, line, "%s", errorStr)
if err.LineNumber != lineNumber {
t.Errorf("Line number should be %d but was %d", lineNumber, err.LineNumber)
}
if err.Line != line {
t.Errorf("Line should be \"%s\" but was \"%s\"", line, err.Line)
}
if err.ErrorStr != errorStr {
t.Errorf("ErrorStr should be \"%s\" but was \"%s\"", errorStr, err.ErrorStr)
}
t.Logf("error: %#v generated message: %s", err, err.Error())
}