Exemplo n.º 1
0
 def test_setRef_withWrongAdrSpace_returnsValueError(self, adr_space):
     cobj = PtrCType(CProgram.int)(adr_space)
     with pytest.raises(ValueError):
         cobj.ref = CProgram.char(AddressSpace(), 1)
Exemplo n.º 2
0
 def test_ptr_onCObj_returnsPtrCObj(self, adr_space, bound_int):
     assert isinstance(bound_int().ptr, PtrCObj)
     assert bound_int().ptr.ctype == PtrCType(CProgram.int)
     assert bound_int().ptr.adr_space is adr_space
Exemplo n.º 3
0
 def test_setRef_onUninitializedCObj_setsRef(self, adr_space):
     refCObj = CProgram.int(adr_space, 1)
     cobj = PtrCType(CProgram.int)(adr_space)
     cobj.ref = refCObj
     assert cobj.ref is refCObj
Exemplo n.º 4
0
 def test_setRef_withNonCType_returnsValueError(self, adr_space):
     cobj = PtrCType(CProgram.int)(adr_space)
     with pytest.raises(ValueError):
         cobj.ref = 1
Exemplo n.º 5
0
 def test_ref_returnsRefCType(self):
     assert PtrCType(CProgram.int).ref == CProgram.int
Exemplo n.º 6
0
 def test_getRef_onInitParam_returnsReferredCObj(self, adr_space):
     refCObj = CProgram.int(adr_space, 1)
     cobj = PtrCType(CProgram.int)(adr_space, refCObj)
     assert cobj.ref is refCObj
Exemplo n.º 7
0
 def test_initialized_onInitParam_returnsTrue(self, adr_space):
     refCObj = CProgram.int(adr_space, 1)
     cobj = PtrCType(CProgram.int)(adr_space, refCObj)
     assert cobj.initialized
Exemplo n.º 8
0
 def test_setRef_withNonCType_returnsValueError(self, adr_space):
     cobj = PtrCType(CProgram.int)(adr_space)
     with pytest.raises(ValueError):
         cobj.ref = 1
Exemplo n.º 9
0
 def test_ptr_onCType_returnsPtrCType(self):
     assert CProgram.int.ptr == PtrCType(CProgram.int)
Exemplo n.º 10
0
 def test_initialized_onNoInitParam_returnsFalse(self, adr_space):
     cobj = PtrCType(CProgram.int)(adr_space)
     assert not cobj.initialized
Exemplo n.º 11
0
 def test_eqNe_onDifferentType_returnsFalse(self):
     assert PtrCType(CProgram.int) != PtrCType(CProgram.unsigned_int)
Exemplo n.º 12
0
 def test_eqNe_onSameType_returnsTrue(self):
     assert PtrCType(CProgram.int) == PtrCType(CProgram.int)
Exemplo n.º 13
0
 def test_ref_onBoundCType_returnsBoundRef(self, adr_space):
     bound_ptr = BoundCType(PtrCType(CProgram.int), adr_space)
     assert isinstance(bound_ptr.ref, BoundCType)
Exemplo n.º 14
0
 def test_initialized_onSetRef_returnsTrue(self, adr_space):
     cobj = PtrCType(CProgram.int)(adr_space)
     cobj.ref = CProgram.int(adr_space, 1)
     assert cobj.initialized
Exemplo n.º 15
0
 def test_initialized_onSetRef_returnsTrue(self, adr_space):
     cobj = PtrCType(CProgram.int)(adr_space)
     cobj.ref = CProgram.int(adr_space, 1)
     assert cobj.initialized
Exemplo n.º 16
0
 def test_setRef_onUninitializedCObj_setsRef(self, adr_space):
     refCObj = CProgram.int(adr_space, 1)
     cobj = PtrCType(CProgram.int)(adr_space)
     cobj.ref = refCObj
     assert cobj.ref is refCObj
Exemplo n.º 17
0
 def test_getRef_onNoInitParam_raisesVarAccessError(self, adr_space):
     cobj = PtrCType(CProgram.int)(adr_space)
     with pytest.raises(VarAccessError):
         _ = cobj.ref
Exemplo n.º 18
0
 def test_setRef_withWrongAdrSpace_returnsValueError(self, adr_space):
     cobj = PtrCType(CProgram.int)(adr_space)
     with pytest.raises(ValueError):
         cobj.ref = CProgram.char(AddressSpace(), 1)
Exemplo n.º 19
0
 def test_str_returnsCConvention(self):
     ptr_ctype = PtrCType(CProgram.int)
     assert str(ptr_ctype) == 'int *'