Skip to content

Commit b4e14ed

Browse files
committed
close #2: updated tests with new constant naming scheme and new constructurs
1 parent b10af93 commit b4e14ed

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

build_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ type builderTestCase struct {
88
}
99

1010
var builderTestCases = []builderTestCase{
11-
{Datagram{Read, BatteryPower, nil}, "[2B 01 04 40 0F 01 5B 58 B4]"},
12-
{Datagram{Read, InverterACPower, nil}, "[2B 01 04 DB 2D 2D 69 AE 55 AB]"},
11+
{Datagram{Read, BatteryPowerW, nil}, "[2B 01 04 40 0F 01 5B 58 B4]"},
12+
{Datagram{Read, InverterACPowerW, nil}, "[2B 01 04 DB 2D 2D 69 AE 55 AB]"},
1313
}
1414

1515
// Test if builder returns expected byte representation
1616
func TestBuilder(t *testing.T) {
17-
builder := DatagramBuilder{}
17+
builder := NewDatagramBuilder()
1818
for _, tc := range builderTestCases {
1919
builder.Build(&tc.Dg)
2020
res := builder.String()
@@ -26,15 +26,14 @@ func TestBuilder(t *testing.T) {
2626

2727
// Test if roundtrip from builder to parser returns the same datagram
2828
func TestBuilderParser(t *testing.T) {
29-
builder := DatagramBuilder{}
30-
parser := DatagramParser{}
31-
parser.Init()
29+
builder := NewDatagramBuilder()
30+
parser := NewDatagramParser()
3231

3332
for _, tc := range builderTestCases {
3433
builder.Build(&tc.Dg)
3534
parser.Reset()
36-
parser.Buffer = builder.Bytes()
37-
parser.Len = len(builder.Bytes())
35+
parser.buffer = builder.Bytes()
36+
parser.length = len(builder.Bytes())
3837
dg, err := parser.Parse()
3938
if err != nil {
4039
t.Errorf(err.Error())

0 commit comments

Comments
 (0)