Esempio n. 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, "")
Esempio n. 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, "")
Esempio n. 3
0
    def test_new_def_type_obj_val(self):
        datatype_1 = uter.struct((uter.char, "a"), (uter.int, "b"))
        dataobj_1 = datatype_1(uter.char(8), uter.int(9))
        print dataobj_1
        self.assertEqual(True, dataobj_1.a._GetValue() == 8, "")
        self.assertEqual(True, dataobj_1.b._GetValue() == 9, "")

        datatype_2 = uter.struct((uter.char, "a"), (uter.short, "b"),
                                 (uter.int, "c"))
        dataobj_2 = datatype_2(uter.char(10), uter.short(11), uter.int(12))
        print dataobj_2
        self.assertEqual(True, dataobj_2.a._GetValue() == 10, "")
        self.assertEqual(True, dataobj_2.b._GetValue() == 11, "")
        self.assertEqual(True, dataobj_2.c._GetValue() == 12, "")

        datatype_3 = uter.struct((uter.char, "a"), (uter.char, "b"))
        dataobj_3 = datatype_3(uter.char(13), uter.char(14))
        print dataobj_3
        self.assertEqual(True, dataobj_3.a._GetValue() == 13, "")
        self.assertEqual(True, dataobj_3.b._GetValue() == 14, "")

        datatype_4 = uter.struct((uter.int, "a"), (uter.char, "b"),
                                 (uter.char, "c"), (uter.char, "d"))
        dataobj_4 = datatype_4(uter.int(15), uter.char(16), uter.char(17),
                               uter.char(18))
        print dataobj_4
        self.assertEqual(True, dataobj_4.a._GetValue() == 15, "")
        self.assertEqual(True, dataobj_4.b._GetValue() == 16, "")
        self.assertEqual(True, dataobj_4.c._GetValue() == 17, "")
        self.assertEqual(True, dataobj_4.d._GetValue() == 18, "")
Esempio n. 4
0
 def test_short(self):
     data_obj = uter.short()
     data_obj._SetValue(1)
     self.assertEqual(True, data_obj._GetValue() == 1, "")
     data_obj._SetValue(-(2 ** 15))
     self.assertEqual(True, data_obj._GetValue() == -(2 ** 15), "")
     data_obj._SetValue((2 ** 15) - 1)
     self.assertEqual(True, data_obj._GetValue() == (2 ** 15) - 1, "")
     data_obj._SetValue(-(2 ** 15) - 1)
     self.assertEqual(True, data_obj._GetValue() == (2 ** 15) - 1, "")
     data_obj._SetValue(2 ** 15)
     self.assertEqual(True, data_obj._GetValue() == -(2 ** 15), "")
Esempio n. 5
0
    def test_short_right(self):
        data_obj = uter.short()

        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(-(1 << 15))
        data_obj._RightShift(1)
        self.assertEqual(True, data_obj._GetValue() % (1 << 16) == (((-(1 << 15)) % (1 << 16)) >> 1), "")
Esempio n. 6
0
    def test_short_left(self):
        data_obj = uter.short()

        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 << 15) - 1)
        data_obj._LeftShift(1)
        self.assertEqual(True, data_obj._GetValue() % (1 << 16) == (((1 << 15) - 1) << 1) & ((1 << 16) - 1), "")
Esempio n. 7
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), "")
Esempio n. 8
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, "")
Esempio n. 9
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, "")
Esempio n. 10
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, "")
Esempio n. 11
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, "")