Object subclass:#IntegerTest
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'Tests - Numbers'
!
!IntegerTest class methodsFor:'orivate'!
test:aBlock
aBlock value ifFalse:[
self halt:'test failed'
]
! !
!IntegerTest class methodsFor:'tests'!
test1
"general conversion & tests"
|maxValPlus1 minValMinus1 t|
self test:[10 printString = '10'].
self test:[100 printString = '100'].
self test:[1000 printString = '1000'].
self test:[10000 printString = '10000'].
self test:[100000 printString = '100000'].
self test:[1000000 printString = '1000000'].
self test:[10000000 printString = '10000000'].
self test:[100000000 printString = '100000000'].
self test:[1000000000 printString = '1000000000'].
self test:[10000000000 printString = '10000000000'].
SmallInteger maxBytes == 4 ifTrue:[
self test:[SmallInteger minVal hexPrintString = '-40000000'].
self test:[SmallInteger maxVal hexPrintString = '3FFFFFFF'].
self test:[SmallInteger minVal == -1073741824].
self test:[SmallInteger maxVal == 1073741823].
maxValPlus1 := 1073741824.
minValMinus1 := -1073741825.
self test:[minValMinus1 hexPrintString = '-40000001'].
self test:[maxValPlus1 hexPrintString = '40000000'].
].
SmallInteger maxBytes == 8 ifTrue:[
self test:[SmallInteger minVal hexPrintString = '-4000000000000000'].
self test:[SmallInteger maxVal hexPrintString = '3FFFFFFFFFFFFFFF'].
self test:[SmallInteger minVal == -4611686018427387904].
self test:[SmallInteger maxVal == 4611686018427387903].
maxValPlus1 := 4611686018427387904.
minValMinus1 := -4611686018427387905.
self test:[minValMinus1 hexPrintString = '-4000000000000001'].
self test:[maxValPlus1 hexPrintString = '4000000000000000'].
].
"arithmetic overFlow checks"
self test:[SmallInteger maxVal + 1 = maxValPlus1].
self test:[SmallInteger minVal - 1 = minValMinus1].
t := SmallInteger maxVal + 1.
self test:[t - 1 == SmallInteger maxVal].
t := SmallInteger minVal - 1.
self test:[t + 1 == SmallInteger minVal].
"
self test1
"
! !
!IntegerTest class methodsFor:'documentation'!
version
^ '$Header$'
! !