Marcel Taeumel uploaded a new version of FFI-Tests to project FFI:
http://source.squeak.org/FFI/FFI-Tests-mt.41.mcz ==================== Summary ==================== Name: FFI-Tests-mt.41 Author: mt Time: 16 May 2021, 2:31:15.844808 pm UUID: adf2f023-0388-9345-b404-41adb308b192 Ancestors: FFI-Tests-mt.40 Adds a minor test to check whether we can read smaller integer types from space allocated for bigger integer types. =============== Diff against FFI-Tests-mt.40 =============== Item was removed: - ----- Method: FFIAllocateTests>>test01AllocateAtomics (in category 'tests - atomics') ----- - test01AllocateAtomics - - self should: [(self allocate: ExternalType void)] raise: Error. - self assert: false equals: (self allocate: ExternalType bool) value. - - self assert: 0 equals: (self allocate: ExternalType int8_t "sbyte") value. - self assert: 0 equals: (self allocate: ExternalType uint8_t "byte") value. - - self assert: 0 equals: (self allocate: ExternalType uint16_t "ushort") value. - self assert: 0 equals: (self allocate: ExternalType int16_t "short") value. - - self assert: 0 equals: (self allocate: ExternalType uint32_t "ulong") value. - self assert: 0 equals: (self allocate: ExternalType int32_t "long") value. - - self assert: 0 equals: (self allocate: ExternalType uint64_t "ulonglong") value. - self assert: 0 equals: (self allocate: ExternalType int64_t "longlong") value. - - self assert: Character null equals: (self allocate: ExternalType schar) value. - self assert: Character null equals: (self allocate: ExternalType char) value. - - self assert: 0.0 equals: (self allocate: ExternalType float) value. - self assert: 0.0 equals: (self allocate: ExternalType double) value.! Item was added: + ----- Method: FFIAllocateTests>>test01AtomicsAllocated (in category 'tests - atomics') ----- + test01AtomicsAllocated + + self should: [(self allocate: ExternalType void)] raise: Error. + self assert: false equals: (self allocate: ExternalType bool) value. + + self assert: 0 equals: (self allocate: ExternalType int8_t "sbyte") value. + self assert: 0 equals: (self allocate: ExternalType uint8_t "byte") value. + + self assert: 0 equals: (self allocate: ExternalType uint16_t "ushort") value. + self assert: 0 equals: (self allocate: ExternalType int16_t "short") value. + + self assert: 0 equals: (self allocate: ExternalType uint32_t "ulong") value. + self assert: 0 equals: (self allocate: ExternalType int32_t "long") value. + + self assert: 0 equals: (self allocate: ExternalType uint64_t "ulonglong") value. + self assert: 0 equals: (self allocate: ExternalType int64_t "longlong") value. + + self assert: Character null equals: (self allocate: ExternalType schar) value. + self assert: Character null equals: (self allocate: ExternalType char) value. + + self assert: 0.0 equals: (self allocate: ExternalType float) value. + self assert: 0.0 equals: (self allocate: ExternalType double) value.! Item was added: + ----- Method: FFIAllocateTests>>test02AtomicsReinterpreted (in category 'tests - atomics') ----- + test02AtomicsReinterpreted + + #( + int8_t int16_t minVal + int8_t int16_t maxVal + int16_t int32_t minVal + int16_t int32_t maxVal + int32_t int64_t minVal + int32_t int64_t maxVal + ) groupsDo: [:smallIntegerTypeName :bigIntegerTypeName :valueSelector | + | smallIntegerType bigIntegerType value data | + smallIntegerType := ExternalType typeNamed: smallIntegerTypeName. + bigIntegerType := ExternalType typeNamed: bigIntegerTypeName. + value := smallIntegerType perform: valueSelector. + data := self allocate: bigIntegerType. + data value: value. + data setContentType: smallIntegerType. + self assert: value equals: data value]! |
Free forum by Nabble | Edit this page |