[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
test[S8Struct] string type identifiers
SwikiCodeRobot @> #testS8StructStringTypeIdentifiers |
"should work with string type identifiers"
| type |
type := S8Struct type: #int -> #int ,(#long -> #long) ,(#string -> #string).
((type#fields basicAt: #int) basicAt: #type) == (S8Ref type: #int) handle ifFalse: [ self error: 'Wrong type for #int' ].
((type#fields basicAt: #long) basicAt: #type) == (S8Ref type: #long) handle ifFalse: [ self error: 'Wrong type for #long' ].
((type#fields basicAt: #string) basicAt: #type) == (S8Ref type: #CString) handle ifFalse: [ self error: 'Wrong type for #string' ].
"should work as expected with void* as a type"
| type b s |
type := S8Struct type: #ptr1 -> 'void *' ,(#ptr2 -> 'void*').
b := NodeBuffer size: 1.
s := S8Struct new: type.
s at: #ptr1 put: S8Ref null.
s at: #ptr2 put: b.
(s @ #ptr1) address = S8Ref null address ifFalse: [ self error: 'Wrong ptr1 value' ].
(s @ #ptr2) address = b address ifFalse: [ self error: 'Wrong ptr2 value' ].