コード例 #1
0
ファイル: test_types.py プロジェクト: tonysimpson/pointbreak
def test_mulitdimensional_array():
    accessor = Accessor(b'\x00\x00\x00\x00\x00\x00')
    uint8_array_3_2 = types.array_type(3, types.array_type(2, types.uint8))
    ref = types.reference(uint8_array_3_2, 0, accessor)
    ref.value[0][0] = 244
    ref.value[2][1] = 221
    assert ref.value[0][0] == 244
    assert ref.value[2][1] == 221
コード例 #2
0
ファイル: test_types.py プロジェクト: tonysimpson/pointbreak
def test_set_whole_array():
    accessor = Accessor(b"\x00\x00\x00\x00\x00")
    uint8_array_5 = types.array_type(5, types.uint8)
    ref = types.reference(uint8_array_5, 0, accessor)
    value = [5, 4, 3, 2, 1]
    ref.value = value
    assert list(ref.value) == value
コード例 #3
0
ファイル: test_types.py プロジェクト: tonysimpson/pointbreak
def test_type_get_array_value():
    accessor = Accessor(b"\x01\x02\x03")
    uint8_array_3 = types.array_type(3, types.uint8)
    ref = types.reference(uint8_array_3, 0, accessor)
    assert ref.value[0] == 1
    assert ref.value[1] == 2
    assert ref.value[2] == 3
コード例 #4
0
ファイル: test_types.py プロジェクト: tonysimpson/pointbreak
def test_struct():
    accessor = Accessor(b'\x00' * 100)
    complex_struct = types.struct_type(
        ('value', types.int64), ('pvalue', types.pointer_type(types.int64)),
        ('avalue', types.array_type(12, types.char)))
    ref = types.reference(complex_struct, 0, accessor)
    ref.value.pvalue = 64
    ref.value.pvalue.value = 32432424
    ref.value.value = 321
    assert ref.value.pvalue.value == 32432424
コード例 #5
0
ファイル: test_types.py プロジェクト: tonysimpson/pointbreak
def test_array_detach():
    accessor = Accessor(b"\x00\x01\x00\x05\x00")
    uint8_array_5 = types.array_type(5, types.uint8)
    ref = types.reference(uint8_array_5, 0, accessor)
    assert ref.detach() == [0, 1, 0, 5, 0]
コード例 #6
0
ファイル: test_types.py プロジェクト: tonysimpson/pointbreak
def test_type_set_array_value():
    accessor = Accessor(b"\x00\x00\x00")
    uint8_array_3 = types.array_type(3, types.uint8)
    ref = types.reference(uint8_array_3, 0, accessor)
    ref.value[1] = 5
    assert ref.value[1] == 5
コード例 #7
0
ファイル: test_types.py プロジェクト: tonysimpson/pointbreak
def test_type_get_array_value_unchecked():
    accessor = Accessor(b"\x01\x02\x03")
    uint8_array_unchecked = types.array_type(0, types.uint8, checked=False)
    ref = types.reference(uint8_array_unchecked, 0, accessor)
    assert ref.value[2] == 3