| 1 | // Copyright 2014 Quoc-Viet Nguyen. All rights reserved. |
| 2 | // This software may be modified and distributed under the terms |
| 3 | // of the BSD license. See the LICENSE file for details. |
| 4 | |
| 5 | package modbus |
| 6 | |
| 7 | import ( |
| 8 | "testing" |
| 9 | ) |
| 10 | |
| 11 | func TestLRC(t *testing.T) { |
| 12 | var lrc lrc |
| 13 | lrc.reset().pushByte(0x01).pushByte(0x03) |
| 14 | lrc.pushBytes([]byte{0x01, 0x0A}) |
| 15 | |
| 16 | if 0xF1 != lrc.value() { |
| 17 | t.Fatalf("lrc expected %v, actual %v", 0xF1, lrc.value()) |
| 18 | } |
| 19 | } |