-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patherror_test.go
42 lines (31 loc) · 1.01 KB
/
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
// Copyright 2016 Tim Heckman. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package fsm
import (
"fmt"
. "gopkg.in/check.v1"
)
func (*TestSuite) TestErrorCode_String(c *C) {
c.Check(ErrorUnknown.String(), Equals, "Unknown")
c.Check(ErrorMachineNotInitialized.String(), Equals, "MachineNotInitialized")
c.Check(ErrorTransitionNotPermitted.String(), Equals, "TransitionNotPermitted")
c.Check(ErrorStateUndefined.String(), Equals, "StateUndefined")
c.Check((ErrorUnknown + 100).String(), Equals, "Unknown")
}
func (t *TestSuite) TestError_Message(c *C) {
var str string
str = t.e.Message()
c.Check(str, Equals, "testMessage")
}
func (t *TestSuite) TestError_Code(c *C) {
var code ErrorCode
code = t.e.Code()
c.Check(code, Equals, ^ErrorCode(0))
}
func (t *TestSuite) TestError_Error(c *C) {
var errStr string
expected := fmt.Sprintf("Unknown (%d): testMessage", ^uint(0))
errStr = t.e.Error()
c.Check(errStr, Equals, expected)
}