| 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 TestCRC(t *testing.T) { |
| 12 | var crc crc |
| 13 | crc.reset() |
| 14 | crc.pushBytes([]byte{0x02, 0x07}) |
| 15 | |
| 16 | if 0x1241 != crc.value() { |
| 17 | t.Fatalf("crc expected %v, actual %v", 0x1241, crc.value()) |
| 18 | } |
| 19 | } |