Example #1
0
 def test_value_obj(self):
     data = uter.char(5)
     data_char = uter.char(data)
     data = uter.uchar(5)
     data_uchar = uter.uchar(data)
     data = uter.short(5)
     data_short = uter.short(data)
     data = uter.ushort(5)
     data_ushort = uter.ushort(data)
     data = uter.int(5)
     data_int = uter.int(data)
     data = uter.uint(5)
     data_uint = uter.uint(data)
     data = uter.long(5)
     data_long = uter.long(data)
     data = uter.ulong(5)
     data_ulong = uter.ulong(data)
     data = uter.longlong(5)
     data_longlong = uter.longlong(data)
     data = uter.ulonglong(5)
     data_ulonglong = uter.ulonglong(data)
     self.assertEqual(True, data_char._GetValue() == 5, "")
     self.assertEqual(True, data_uchar._GetValue() == 5, "")
     self.assertEqual(True, data_short._GetValue() == 5, "")
     self.assertEqual(True, data_ushort._GetValue() == 5, "")
     self.assertEqual(True, data_int._GetValue() == 5, "")
     self.assertEqual(True, data_uint._GetValue() == 5, "")
     self.assertEqual(True, data_long._GetValue() == 5, "")
     self.assertEqual(True, data_ulong._GetValue() == 5, "")
     self.assertEqual(True, data_longlong._GetValue() == 5, "")
     self.assertEqual(True, data_ulonglong._GetValue() == 5, "")
Example #2
0
 def test_setnum(self):
     data_char = uter.char()
     data_uchar = uter.uchar()
     data_short = uter.short()
     data_ushort = uter.ushort()
     data_int = uter.int()
     data_uint = uter.uint()
     data_long = uter.long()
     data_ulong = uter.ulong()
     data_longlong = uter.longlong()
     data_ulonglong = uter.ulonglong()
     data_char._SetValue(5)
     data_uchar._SetValue(5)
     data_short._SetValue(5)
     data_ushort._SetValue(5)
     data_int._SetValue(5)
     data_uint._SetValue(5)
     data_long._SetValue(5)
     data_ulong._SetValue(5)
     data_longlong._SetValue(5)
     data_ulonglong._SetValue(5)
     self.assertEqual(True, data_char._GetValue() == 5, "")
     self.assertEqual(True, data_uchar._GetValue() == 5, "")
     self.assertEqual(True, data_short._GetValue() == 5, "")
     self.assertEqual(True, data_ushort._GetValue() == 5, "")
     self.assertEqual(True, data_int._GetValue() == 5, "")
     self.assertEqual(True, data_uint._GetValue() == 5, "")
     self.assertEqual(True, data_long._GetValue() == 5, "")
     self.assertEqual(True, data_ulong._GetValue() == 5, "")
     self.assertEqual(True, data_longlong._GetValue() == 5, "")
     self.assertEqual(True, data_ulonglong._GetValue() == 5, "")
Example #3
0
 def test_ushort(self):
     data_obj = uter.ushort()
     data_obj._SetValue(1)
     self.assertEqual(True, data_obj._GetValue() == 1, "")
     data_obj._SetValue(0)
     self.assertEqual(True, data_obj._GetValue() == 0, "")
     data_obj._SetValue((2 ** 16) - 1)
     self.assertEqual(True, data_obj._GetValue() == (2 ** 16) - 1, "")
     data_obj._SetValue(-1)
     self.assertEqual(True, data_obj._GetValue() == (2 ** 16) - 1, "")
     data_obj._SetValue(2 ** 16)
     self.assertEqual(True, data_obj._GetValue() == 0, "")
Example #4
0
    def test_ushort_right(self):
        data_obj = uter.ushort()

        data_obj._SetValue(2)
        data_obj._RightShift(1)
        self.assertEqual(True, data_obj._GetValue() == 1, "")
        
        data_obj._SetValue(4)
        data_obj._RightShift(2)
        self.assertEqual(True, data_obj._GetValue() == 1, "")
        
        data_obj._SetValue(0)
        data_obj._RightShift(1)
        self.assertEqual(True, data_obj._GetValue() == 0, "")
Example #5
0
    def test_ushort_left(self):
        data_obj = uter.ushort()

        data_obj._SetValue(1)
        data_obj._LeftShift(1)
        self.assertEqual(True, data_obj._GetValue() == 2, "")
        
        data_obj._SetValue(1)
        data_obj._LeftShift(2)
        self.assertEqual(True, data_obj._GetValue() == 4, "")
        
        data_obj._SetValue((1 << 16) - 1)
        data_obj._LeftShift(1)
        self.assertEqual(True, data_obj._GetValue() == ((((1 << 16) - 1) << 1) & ((1 << 16) - 1)), "")
Example #6
0
 def test_match(self):
     data_char = uter.char()
     data_uchar = uter.uchar()
     data_short = uter.short()
     data_ushort = uter.ushort()
     data_int = uter.int()
     data_uint = uter.uint()
     data_long = uter.long()
     data_ulong = uter.ulong()
     data_longlong = uter.longlong()
     data_ulonglong = uter.ulonglong()
     self.assertEqual(True, uter.char._MatchObj(data_char), "")
     self.assertEqual(True, uter.uchar._MatchObj(data_uchar), "")
     self.assertEqual(True, uter.short._MatchObj(data_short), "")
     self.assertEqual(True, uter.ushort._MatchObj(data_ushort), "")
     self.assertEqual(True, uter.int._MatchObj(data_int), "")
     self.assertEqual(True, uter.uint._MatchObj(data_uint), "")
     self.assertEqual(True, uter.long._MatchObj(data_long), "")
     self.assertEqual(True, uter.ulong._MatchObj(data_ulong), "")
     self.assertEqual(True, uter.longlong._MatchObj(data_longlong), "")
     self.assertEqual(True, uter.ulonglong._MatchObj(data_ulonglong), "")
     self.assertEqual(True, not uter.char._MatchObj(data_uchar), "")
     self.assertEqual(True, not uter.uchar._MatchObj(data_char), "")
     self.assertEqual(True, not uter.short._MatchObj(data_ushort), "")
     self.assertEqual(True, not uter.ushort._MatchObj(data_short), "")
     self.assertEqual(True, not uter.int._MatchObj(data_uint), "")
     self.assertEqual(True, not uter.uint._MatchObj(data_int), "")
     self.assertEqual(True, not uter.long._MatchObj(data_ulong), "")
     self.assertEqual(True, not uter.ulong._MatchObj(data_long), "")
     self.assertEqual(True, not uter.longlong._MatchObj(data_ulonglong), "")
     self.assertEqual(True, not uter.ulonglong._MatchObj(data_longlong), "")
     self.assertEqual(True, not uter.char._MatchObj(1), "")
     self.assertEqual(True, not uter.uchar._MatchObj(1), "")
     self.assertEqual(True, not uter.short._MatchObj(1), "")
     self.assertEqual(True, not uter.ushort._MatchObj(1), "")
     self.assertEqual(True, not uter.int._MatchObj(1), "")
     self.assertEqual(True, not uter.uint._MatchObj(1), "")
     self.assertEqual(True, not uter.long._MatchObj(1), "")
     self.assertEqual(True, not uter.ulong._MatchObj(1), "")
     self.assertEqual(True, not uter.longlong._MatchObj(1), "")
     self.assertEqual(True, not uter.ulonglong._MatchObj(1), "")
Example #7
0
 def test_gettype(self):
     data_char = uter.char()
     data_uchar = uter.uchar()
     data_short = uter.short()
     data_ushort = uter.ushort()
     data_int = uter.int()
     data_uint = uter.uint()
     data_long = uter.long()
     data_ulong = uter.ulong()
     data_longlong = uter.longlong()
     data_ulonglong = uter.ulonglong()
     self.assertEqual(True, data_char._GetType() == uter.char, "")
     self.assertEqual(True, data_uchar._GetType() == uter.uchar, "")
     self.assertEqual(True, data_short._GetType() == uter.short, "")
     self.assertEqual(True, data_ushort._GetType() == uter.ushort, "")
     self.assertEqual(True, data_int._GetType() == uter.int, "")
     self.assertEqual(True, data_uint._GetType() == uter.uint, "")
     self.assertEqual(True, data_long._GetType() == uter.long, "")
     self.assertEqual(True, data_ulong._GetType() == uter.ulong, "")
     self.assertEqual(True, data_longlong._GetType() == uter.longlong, "")
     self.assertEqual(True, data_ulonglong._GetType() == uter.ulonglong, "")
Example #8
0
 def test_getaddress(self):
     data_char = uter.char()
     data_uchar = uter.uchar()
     data_short = uter.short()
     data_ushort = uter.ushort()
     data_int = uter.int()
     data_uint = uter.uint()
     data_long = uter.long()
     data_ulong = uter.ulong()
     data_longlong = uter.longlong()
     data_ulonglong = uter.ulonglong()
     self.assertEqual(True, data_char._GetAddress() != 0, "")
     self.assertEqual(True, data_uchar._GetAddress() != 0, "")
     self.assertEqual(True, data_short._GetAddress() != 0, "")
     self.assertEqual(True, data_ushort._GetAddress() != 0, "")
     self.assertEqual(True, data_int._GetAddress() != 0, "")
     self.assertEqual(True, data_uint._GetAddress() != 0, "")
     self.assertEqual(True, data_long._GetAddress() != 0, "")
     self.assertEqual(True, data_ulong._GetAddress() != 0, "")
     self.assertEqual(True, data_longlong._GetAddress() != 0, "")
     self.assertEqual(True, data_ulonglong._GetAddress() != 0, "")
Example #9
0
 def test_value_default(self):
     data_char = uter.char()
     data_uchar = uter.uchar()
     data_short = uter.short()
     data_ushort = uter.ushort()
     data_int = uter.int()
     data_uint = uter.uint()
     data_long = uter.long()
     data_ulong = uter.ulong()
     data_longlong = uter.longlong()
     data_ulonglong = uter.ulonglong()
     self.assertEqual(True, data_char._GetValue() == 0, "")
     self.assertEqual(True, data_uchar._GetValue() == 0, "")
     self.assertEqual(True, data_short._GetValue() == 0, "")
     self.assertEqual(True, data_ushort._GetValue() == 0, "")
     self.assertEqual(True, data_int._GetValue() == 0, "")
     self.assertEqual(True, data_uint._GetValue() == 0, "")
     self.assertEqual(True, data_long._GetValue() == 0, "")
     self.assertEqual(True, data_ulong._GetValue() == 0, "")
     self.assertEqual(True, data_longlong._GetValue() == 0, "")
     self.assertEqual(True, data_ulonglong._GetValue() == 0, "")
Example #10
0
 def test_print(self):
     data = uter.char()
     print data
     data = uter.uchar()
     print data
     data = uter.short()
     print data
     data = uter.ushort()
     print data
     data = uter.int()
     print data
     data = uter.uint()
     print data
     data = uter.long()
     print data
     data = uter.ulong()
     print data
     data = uter.longlong()
     print data
     data = uter.ulonglong()
     print data
     self.assertEqual(True, True, "")