lrc_test.go 431 B

12345678910111213141516171819
  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. package modbus
  5. import (
  6. "testing"
  7. )
  8. func TestLRC(t *testing.T) {
  9. var lrc lrc
  10. lrc.reset().pushByte(0x01).pushByte(0x03)
  11. lrc.pushBytes([]byte{0x01, 0x0A})
  12. if 0xF1 != lrc.value() {
  13. t.Fatalf("lrc expected %v, actual %v", 0xF1, lrc.value())
  14. }
  15. }