コード例 #1
0
 def test_get_target_answer_two(self):
     # 0xAABBCCDD --> 2864434397
     # Reversed 0xDDCCBBAA --> 3721182122
     testWord = EncoderDoubleWord('0xAABBCCDD')
     # Answer should be 573785174 --> 0x22 33 44 56
     testAnswer = testWord.get_subtraction_target()
     self.assertEqual(testAnswer.get_byte_array()[0], "22")
     self.assertEqual(testAnswer.get_byte_array()[1], "33")
     self.assertEqual(testAnswer.get_byte_array()[2], "44")
     self.assertEqual(testAnswer.get_byte_array()[3], "56")
コード例 #2
0
 def test_get_target_answer_one(self):
     # 0x01020304 --> 16909060
     # Reversed 0x04030201 --> 67305985
     testWord = EncoderDoubleWord('0x01020304')
     # Answer should be 4227661310 --> 0xFB FC FD FF
     testAnswer = testWord.get_subtraction_target()
     self.assertEqual(testAnswer.get_byte_array()[0], "fb")
     self.assertEqual(testAnswer.get_byte_array()[1], "fc")
     self.assertEqual(testAnswer.get_byte_array()[2], "fd")
     self.assertEqual(testAnswer.get_byte_array()[3], "ff")
コード例 #3
0
 def test_nominal_base_10(self):
     testWord = EncoderDoubleWord(10)
     self.assertEqual(testWord.get_base_ten(), 10)
     self.assertEqual(testWord.get_base_sixteen(), 'a')
     self.assertEqual(testWord.get_all_digits_base_sixteen(), '0000000a')
     self.assertEqual(testWord.get_all_digits_base_sixteen(pretty=True),
                      '0x0000000a')
コード例 #4
0
 def test_signed_too_small(self):
     with self.assertRaises(EncoderDoubleWordTooSmallError):
         testWord = EncoderDoubleWord(-2147483649)
コード例 #5
0
 def test_unsigned_too_big(self):
     with self.assertRaises(EncoderDoubleWordTooLargeError):
         testWord = EncoderDoubleWord(4294967296)
コード例 #6
0
 def test_get_byte_array_reverse(self):
     testWord = EncoderDoubleWord(16909060)
     self.assertEqual(testWord.get_byte_array_reverse()[0], "04")
     self.assertEqual(testWord.get_byte_array_reverse()[1], "03")
     self.assertEqual(testWord.get_byte_array_reverse()[2], "02")
     self.assertEqual(testWord.get_byte_array_reverse()[3], "01")