Esempio n. 1
0
 def test02(self):
     data = 100*"1"
     expected_result = 2326594156
     result = digital.crc32(data)
     #print hex(result)
     
     self.assertEqual(expected_result, result)
Esempio n. 2
0
    def test03(self):
        data = 10*"0123456789"
        expected_result = 3774345973
        result = digital.crc32(data)
        #print hex(result)

        self.assertEqual(expected_result, result)
Esempio n. 3
0
    def test03 (self):
        data = 10*"0123456789"
        expected_result = 3774345973
        result = digital_swig.crc32(data)
        #print hex(result)

        self.assertEqual (expected_result, result)
Esempio n. 4
0
 def test01(self):
     data = 100*"0"
     expected_result = 2943744955
     result = digital.crc32(data)
     #print hex(result)
     
     self.assertEqual(expected_result, result)
Esempio n. 5
0
 def test02 (self):
     data = 100*"1"
     expected_result = 2326594156
     result = digital_swig.crc32(data)
     #print hex(result)
     
     self.assertEqual (expected_result, result)
Esempio n. 6
0
 def test01 (self):
     data = 100*"0"
     expected_result = 2943744955
     result = digital_swig.crc32(data)
     #print hex(result)
     
     self.assertEqual (expected_result, result)
Esempio n. 7
0
def check_crc32(s):
    if len(s) < 4:
        return (False, '')
    msg = s[:-4]
    #print "msg = '%s'" % (msg,)
    actual = digital_swig.crc32(msg)
    (expected,) = struct.unpack(">I", s[-4:])
    # print "actual =", hex(actual), "expected =", hex(expected)
    return (actual == expected, msg)
Esempio n. 8
0
def check_crc32(s):
    if len(s) < 4:
        return (False, '')
    msg = s[:-4]
    #print "msg = '%s'" % (msg,)
    actual = digital_swig.crc32(msg)
    (expected, ) = struct.unpack(">I", s[-4:])
    # print "actual =", hex(actual), "expected =", hex(expected)
    return (actual == expected, msg)
Esempio n. 9
0
def check_crc32(s):
    if len(s) < 4:
        return (False, '')
    msg = s[:-4]
    cbits = 0
    #print "msg = '%s'" % (msg,)
    actual = digital.crc32(msg)
    bin_actual = bin(actual)
    (expected,) = struct.unpack(">I", s[-4:])
    bin_expected = bin(expected)
  #  print bin_expected
   # print bin_actual
    #print max(len(bin_actual),len(bin_expected))-2
    for i in range(max(len(bin_actual),len(bin_expected))-2):
	if bin_expected[i+2:i+3]==bin_actual[i+2:i+3]:
	    cbits=cbits+1
    #print cbits,len(bin_actual)
    # print "actual =", hex(actual), "expected =", hex(expected)
    return (actual == expected, msg, cbits, len(bin_actual)-2)
Esempio n. 10
0
def gen_and_append_crc32(s):
    crc = digital_swig.crc32(s)
    return s + struct.pack(">I", gru.hexint(crc) & 0xFFFFFFFF)
Esempio n. 11
0
def gen_and_append_crc32(s):
    crc = digital_swig.crc32(s)
    return s + struct.pack(">I", gru.hexint(crc) & 0xFFFFFFFF)