-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdec_test.go
executable file
·78 lines (66 loc) · 2.46 KB
/
dec_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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package uu
import (
"gopkg.in/check.v1"
)
//TstDec is the test suit
type TstDec struct{}
var _ = check.Suite(&TstDec{})
//TestDecodePack1 tests DecodePack
func (s *TstDec) TestDecodePack1(c *check.C) {
lRes, lSts := DecodePack([4]byte{0x25, 0x20, 0x5E, 0x48})
c.Check(lSts, check.Equals, true)
c.Check(lRes, check.Equals, [3]byte{0x14, 0x0F, 0xA8})
}
//TestFindLevel tests hello world
func (s *TstDec) TestDecodePack2(c *check.C) {
lRes, lSts := DecodePack([4]byte{0x25, 0x50, 0x20, 0x20})
c.Check(lSts, check.Equals, true)
c.Check(lRes, check.Equals, [3]byte{0x17, 0x00, 0x00})
}
//TestFindLevel tests hello world
func (s *TstDec) TestDecodePack3(c *check.C) {
lRes, lSts := DecodePack([4]byte{0x25, 0x50, 0x60, 0x60})
c.Check(lSts, check.Equals, true)
c.Check(lRes, check.Equals, [3]byte{0x17, 0x00, 0x00})
}
//TestFindLevel tests hello world
func (s *TstDec) TestDecodePackErr1(c *check.C) {
lRes, lSts := DecodePack([4]byte{0x0A, 0x50, 0x60, 0x60})
c.Check(lSts, check.Equals, false)
c.Check(lRes, check.Equals, [3]byte{0x0, 0x0, 0x0})
}
//TestFindLevel tests hello world
func (s *TstDec) TestDecodeLineInvalidLineLen(c *check.C) {
lIn := make([]byte, MaxBytesPerEncLine+1)
lRes, lErr := DecodeLine(lIn)
c.Check(lErr, check.Equals, ErrInvalidLineLen)
c.Check(lRes, check.IsNil)
}
//TestFindLevel tests hello world
func (s *TstDec) TestDecodeLineInvalidDataLen1(c *check.C) {
lIn := []byte{UUCharStart + 2, UUCharStart, UUCharStart, UUCharStart, PCharCR, PCharNewline}
lRes, lErr := DecodeLine(lIn)
c.Check(lErr, check.Equals, ErrInvalidDataLen)
c.Check(lRes, check.IsNil)
}
//TestFindLevel tests hello world
func (s *TstDec) TestDecodeLineInvalidData1(c *check.C) {
lIn := []byte{0x61, PCharCR, PCharNewline}
lRes, lErr := DecodeLine(lIn)
c.Check(lErr, check.Equals, ErrInvalidData)
c.Check(lRes, check.IsNil)
}
//TestFindLevel tests hello world
func (s *TstDec) TestDecodeLineInvalidData2(c *check.C) {
lIn := []byte{UUCharStart + 2, UUCharStart, UUCharStart, UUCharStart - 2, UUCharStart, PCharCR, PCharNewline}
lRes, lErr := DecodeLine(lIn)
c.Check(lErr, check.Equals, ErrInvalidData)
c.Check(lRes, check.IsNil)
}
//TestFindLevel tests hello world
func (s *TstDec) TestDecodeLine1(c *check.C) {
lIn := []byte("::'1T<#HO+W=W=RYW:6MI<&5D:6$N;W)G#0H \r\n")
lResBytes, _ := DecodeLine(lIn[:len(lIn)])
lRes := string(lResBytes)
c.Check(lRes, check.Equals, "http://www.wikipedia.org\r\n")
}