def test_base_call(self): fun = uter.export.function("fun_0_in_so") print fun obj = fun._Call() self.assertEqual(True, obj._GetValue() == 20, "") fun = uter.export.function("fun_1_in_so") obj = fun._Call(uter.int(5)) self.assertEqual(True, obj._GetValue() == 25, "") fun = uter.export.function("fun_2_in_so") obj = fun._Call(uter.int(5), uter.int(10)) self.assertEqual(True, obj._GetValue() == 35, "") fun = uter.export.function("fun_3_in_so") obj = fun._Call(uter.int(5), uter.int(10), uter.int(20)) self.assertEqual(True, obj._GetValue() == 55, "") fun = uter.export.function("fun_v_in_so") obj = fun._Call() self.assertEqual(True, obj == uter.void, "") fun = uter.export.function("fun_p_in_so") obj = fun._Call(uter.dopoint(uter.int(5)), uter.dopoint(uter.int(10))) self.assertEqual(True, obj._GetValue() == 35, "") fun = uter.export.function("fun_pp_in_so") obj = fun._Call(uter.dopoint(uter.dopoint(uter.int(5))), uter.dopoint(uter.dopoint(uter.int(10)))) self.assertEqual(True, obj._GetValue() == 35, "") fun = uter.export.function("fun_a_int_so") x = uter.array(uter.int, 1)() x[0]._SetValue(5) y = uter.array(uter.int, 1)() y[0]._SetValue(10) obj = fun._Call(x, y) self.assertEqual(True, obj._GetValue() == 35, "") fun = uter.export.function("fun_aa_int_so") fun = uter.export.function("fun_st_in_so") sttype = uter.export.struct("st_arg") stobj = sttype() stobj.x._SetValue(5) stobj.y._SetValue(10) obj = fun._Call(stobj) self.assertEqual(True, obj._GetValue() == 35, "") fun = uter.export.function("fun_stp_in_so") sttype = uter.export.struct("st_arg") stobj = sttype() stobj.x._SetValue(5) stobj.y._SetValue(10) obj = fun._Call(uter.dopoint(stobj)) self.assertEqual(True, obj._GetValue() == 35, "")
def test_def_base(self): arraytype_1 = uter.array(uter.int, 5) arraytype_2 = uter.array(uter.int, (5)) arraytype_3 = uter.array(uter.int, (5, )) arraytype_4 = uter.array(uter.int, (5, 5)) arraytype_5 = uter.array(uter.int, (5, 5, 4)) arraytype_6 = uter.array(uter.int, [5]) arraytype_7 = uter.array(uter.int, [ 5, ]) arraytype_8 = uter.array(uter.int, [5, 5]) arraytype_9 = uter.array(uter.int, [5, 5, 4]) print arraytype_1 print arraytype_2 print arraytype_3 print arraytype_4 print arraytype_5 print arraytype_6 print arraytype_7 print arraytype_8 print arraytype_9 self.assertEqual(True, arraytype_1._GetSize() == 20, "") self.assertEqual(True, arraytype_2._GetSize() == 20, "") self.assertEqual(True, arraytype_3._GetSize() == 20, "") self.assertEqual(True, arraytype_4._GetSize() == 100, "") self.assertEqual(True, arraytype_5._GetSize() == 400, "") self.assertEqual(True, arraytype_6._GetSize() == 20, "") self.assertEqual(True, arraytype_7._GetSize() == 20, "") self.assertEqual(True, arraytype_8._GetSize() == 100, "") self.assertEqual(True, arraytype_9._GetSize() == 400, "") self.assertEqual(True, arraytype_1._GetAlign() == 4, "") self.assertEqual(True, arraytype_2._GetAlign() == 4, "") self.assertEqual(True, arraytype_3._GetAlign() == 4, "") self.assertEqual(True, arraytype_4._GetAlign() == 4, "") self.assertEqual(True, arraytype_5._GetAlign() == 4, "") self.assertEqual(True, arraytype_6._GetAlign() == 4, "") self.assertEqual(True, arraytype_7._GetAlign() == 4, "") self.assertEqual(True, arraytype_8._GetAlign() == 4, "") self.assertEqual(True, arraytype_9._GetAlign() == 4, "") self.assertEqual(True, arraytype_1._GetFinalType() == uter.int, "") self.assertEqual(True, arraytype_2._GetFinalType() == uter.int, "") self.assertEqual(True, arraytype_3._GetFinalType() == uter.int, "") self.assertEqual(True, arraytype_4._GetFinalType() == uter.int, "") self.assertEqual(True, arraytype_5._GetFinalType() == uter.int, "") self.assertEqual(True, arraytype_6._GetFinalType() == uter.int, "") self.assertEqual(True, arraytype_7._GetFinalType() == uter.int, "") self.assertEqual(True, arraytype_8._GetFinalType() == uter.int, "") self.assertEqual(True, arraytype_9._GetFinalType() == uter.int, "") self.assertEqual(True, uter.int == arraytype_1._GetFinalType(), "") self.assertEqual(True, uter.int == arraytype_2._GetFinalType(), "") self.assertEqual(True, uter.int == arraytype_3._GetFinalType(), "") self.assertEqual(True, uter.int == arraytype_4._GetFinalType(), "") self.assertEqual(True, uter.int == arraytype_5._GetFinalType(), "") self.assertEqual(True, uter.int == arraytype_6._GetFinalType(), "") self.assertEqual(True, uter.int == arraytype_7._GetFinalType(), "") self.assertEqual(True, uter.int == arraytype_8._GetFinalType(), "") self.assertEqual(True, uter.int == arraytype_9._GetFinalType(), "")
def test_subarry(self): arraytype = uter.array(uter.int, (5, 2)) arraydata = arraytype() print arraydata print arraydata[0] print arraydata[1] print arraydata[2] print arraydata[3] print arraydata[4] self.assertEqual(True, True, "")
def test_all(self): self.assertEqual(True, type(uter.char) is uter._UterMetaClass, "") self.assertEqual(True, type(uter.uchar) is uter._UterMetaClass, "") self.assertEqual(True, type(uter.short) is uter._UterMetaClass, "") self.assertEqual(True, type(uter.ushort) is uter._UterMetaClass, "") self.assertEqual(True, type(uter.int) is uter._UterMetaClass, "") self.assertEqual(True, type(uter.uint) is uter._UterMetaClass, "") self.assertEqual(True, type(uter.long) is uter._UterMetaClass, "") self.assertEqual(True, type(uter.ulong) is uter._UterMetaClass, "") self.assertEqual(True, type(uter.longlong) is uter._UterMetaClass, "") self.assertEqual(True, type(uter.ulonglong) is uter._UterMetaClass, "") self.assertEqual(True, type(uter.float) is uter._UterMetaClass, "") self.assertEqual(True, type(uter.double) is uter._UterMetaClass, "") self.assertEqual(True, isinstance(uter.char, uter._UterMetaClass), "") self.assertEqual(True, isinstance(uter.uchar, uter._UterMetaClass), "") self.assertEqual(True, isinstance(uter.short, uter._UterMetaClass), "") self.assertEqual(True, isinstance(uter.ushort, uter._UterMetaClass), "") self.assertEqual(True, isinstance(uter.int, uter._UterMetaClass), "") self.assertEqual(True, isinstance(uter.uint, uter._UterMetaClass), "") self.assertEqual(True, isinstance(uter.long, uter._UterMetaClass), "") self.assertEqual(True, isinstance(uter.ulong, uter._UterMetaClass), "") self.assertEqual(True, isinstance(uter.longlong, uter._UterMetaClass), "") self.assertEqual(True, isinstance(uter.ulonglong, uter._UterMetaClass), "") self.assertEqual(True, isinstance(uter.float, uter._UterMetaClass), "") self.assertEqual(True, isinstance(uter.double, uter._UterMetaClass), "") datatype = uter.struct((uter.char, "a"), (uter.char, "b")) self.assertEqual(True, type(datatype) is uter._UterMetaClass, "") self.assertEqual(True, isinstance(datatype, uter._UterMetaClass), "") datatype = uter.union((uter.char, "a"), (uter.char, "b")) self.assertEqual(True, type(datatype) is uter._UterMetaClass, "") self.assertEqual(True, isinstance(datatype, uter._UterMetaClass), "") datatype = uter.enum(("a", 1), ("b", 3)) self.assertEqual(True, type(datatype) is uter._UterMetaClass, "") self.assertEqual(True, isinstance(datatype, uter._UterMetaClass), "") datatype = uter.point(uter.int) self.assertEqual(True, type(datatype) is uter._UterMetaClass, "") self.assertEqual(True, isinstance(datatype, uter._UterMetaClass), "") datatype = uter.array(uter.int, 8) self.assertEqual(True, type(datatype) is uter._UterMetaClass, "") self.assertEqual(True, isinstance(datatype, uter._UterMetaClass), "") datatype = uter.typedef(uter.int, "xxx") self.assertEqual(True, type(datatype) is uter._UterMetaClass, "") self.assertEqual(True, isinstance(datatype, uter._UterMetaClass), "")
def test_string_get_01(self): arraytype = uter.array(uter.uchar, 10) arraydata = arraytype() arraydata[0]._SetValue(ord("H")) arraydata[1]._SetValue(ord("e")) arraydata[2]._SetValue(ord("l")) arraydata[3]._SetValue(ord("l")) arraydata[4]._SetValue(ord("o")) arraydata[5]._SetValue(0) getstr = uter.string.ascii.get(arraydata._GetAddress()) self.assertEqual("Hello", getstr, "")
def test_data_1v(self): arraytype = uter.array(uter.int, 5) arraydata = arraytype() print arraydata arraydata[0]._SetValue(1) arraydata[1]._SetValue(2) arraydata[2]._SetValue(3) arraydata[3]._SetValue(4) arraydata[4]._SetValue(5) self.assertEqual(True, arraydata[0]._GetValue() == 1, "") self.assertEqual(True, arraydata[1]._GetValue() == 2, "") self.assertEqual(True, arraydata[2]._GetValue() == 3, "") self.assertEqual(True, arraydata[3]._GetValue() == 4, "") self.assertEqual(True, arraydata[4]._GetValue() == 5, "")
def test_data_2v(self): arraytype = uter.array(uter.int, (5, 2)) arraydata = arraytype() print arraydata arraydata[0][0]._SetValue(1) arraydata[0][1]._SetValue(2) arraydata[1][0]._SetValue(3) arraydata[1][1]._SetValue(4) arraydata[2][0]._SetValue(5) arraydata[2][1]._SetValue(6) arraydata[3][0]._SetValue(7) arraydata[3][1]._SetValue(8) arraydata[4][0]._SetValue(9) arraydata[4][1]._SetValue(0) self.assertEqual(True, arraydata[0][0]._GetValue() == 1, "") self.assertEqual(True, arraydata[0][1]._GetValue() == 2, "") self.assertEqual(True, arraydata[1][0]._GetValue() == 3, "") self.assertEqual(True, arraydata[1][1]._GetValue() == 4, "") self.assertEqual(True, arraydata[2][0]._GetValue() == 5, "") self.assertEqual(True, arraydata[2][1]._GetValue() == 6, "") self.assertEqual(True, arraydata[3][0]._GetValue() == 7, "") self.assertEqual(True, arraydata[3][1]._GetValue() == 8, "") self.assertEqual(True, arraydata[4][0]._GetValue() == 9, "") self.assertEqual(True, arraydata[4][1]._GetValue() == 0, "")
def test_string_set_02(self): arraytype = uter.array(uter.uchar, 10) arraydata = arraytype() arraydata[0]._SetValue(255) arraydata[1]._SetValue(255) arraydata[2]._SetValue(255) arraydata[3]._SetValue(255) arraydata[4]._SetValue(255) arraydata[5]._SetValue(255) arraydata[6]._SetValue(255) arraydata[7]._SetValue(255) arraydata[8]._SetValue(255) arraydata[9]._SetValue(255) uter.string.ascii.set(arraydata._GetAddress(), "Hello", 3) self.assertEqual(True, arraydata[0]._GetValue() == ord("H"), "") self.assertEqual(True, arraydata[1]._GetValue() == ord("e"), "") self.assertEqual(True, arraydata[2]._GetValue() == ord("l"), "") self.assertEqual(True, arraydata[3]._GetValue() == 255, "") self.assertEqual(True, arraydata[4]._GetValue() == 255, "") self.assertEqual(True, arraydata[5]._GetValue() == 255, "") self.assertEqual(True, arraydata[6]._GetValue() == 255, "") self.assertEqual(True, arraydata[7]._GetValue() == 255, "") self.assertEqual(True, arraydata[8]._GetValue() == 255, "") self.assertEqual(True, arraydata[9]._GetValue() == 255, "")