Example #1
0
 def testChecksum(self):
     "Test calcChecksum function"
     self.assertEquals(calcChecksum(""), 0)
     self.assertEquals(calcChecksum("\1"), 0x01000000)
     self.assertEquals(calcChecksum("\x01\x02\x03\x04\x10\x20\x30\x40"),
                       0x11223344)
     self.assertEquals(calcChecksum("\x81"), 0x81000000L)
     self.assertEquals(calcChecksum("\x81\x02"), 0x81020000L)
     self.assertEquals(calcChecksum("\x81\x02\x03"), 0x81020300L)
     self.assertEquals(calcChecksum("\x81\x02\x03\x04"), 0x81020304L)
     self.assertEquals(calcChecksum("\x81\x02\x03\x04\x05"), 0x86020304L)
     self.assertEquals(calcChecksum("\x41\x02\x03\x04\xD0\x20\x30\x40"),
                       0x11223344)
     self.assertEquals(calcChecksum("\xD1\x02\x03\x04\x40\x20\x30\x40"),
                       0x11223344)
     self.assertEquals(calcChecksum("\x81\x02\x03\x04\x90\x20\x30\x40"),
                       0x11223344)
     self.assertEquals(calcChecksum("\x7F\xFF\xFF\xFF\x00\x00\x00\x01"),
                       0x80000000L)
 def testChecksum(self):
     "Test calcChecksum function"
     self.assertEquals(calcChecksum(b""), 0)
     self.assertEquals(calcChecksum(b"\1"), 0x01000000)
     self.assertEquals(calcChecksum(b"\x01\x02\x03\x04\x10\x20\x30\x40"), 0x11223344)
     self.assertEquals(calcChecksum(b"\x81"), 0x81000000)
     self.assertEquals(calcChecksum(b"\x81\x02"), 0x81020000)
     self.assertEquals(calcChecksum(b"\x81\x02\x03"), 0x81020300)
     self.assertEquals(calcChecksum(b"\x81\x02\x03\x04"), 0x81020304)
     self.assertEquals(calcChecksum(b"\x81\x02\x03\x04\x05"), 0x86020304)
     self.assertEquals(calcChecksum(b"\x41\x02\x03\x04\xD0\x20\x30\x40"), 0x11223344)
     self.assertEquals(calcChecksum(b"\xD1\x02\x03\x04\x40\x20\x30\x40"), 0x11223344)
     self.assertEquals(calcChecksum(b"\x81\x02\x03\x04\x90\x20\x30\x40"), 0x11223344)
     self.assertEquals(calcChecksum(b"\x7F\xFF\xFF\xFF\x00\x00\x00\x01"), 0x80000000)