1 UnitTests define: #WordArray &parents: {TestCase}.
3 tc@(UnitTests WordArray traits) isEmpty
6 tc assert: wa isEmpty description: 'New WordArray is not empty'.
9 tc@(UnitTests WordArray traits) size
12 tc assert: wa size = 0 description: 'Empty WordArray has non-zero size'.
15 tc@(UnitTests WordArray traits) includes
17 wa ::= WordArray new &capacity: 5.
19 tc assert: (wa includes: 2) description: 'First inserted object not found'.
21 tc assert: (wa includes: 10) description: 'Second inserted object not found'.
22 tc deny: (wa includes: 4) description: 'Found object which was not added'.
25 tc@(UnitTests WordArray traits) at
27 wa ::= WordArray new &capacity: 6.
30 tc assert: (wa at: 0) = 10 description: 'First object retrieved isn\'t object stored'.
31 tc assert: (wa at: 5) = 1000 description: 'Last object retrieved isn\'t object stored'.
34 tc@(UnitTests WordArray traits) accepts
37 tc assert: (wa accepts: 16rFFFFFFFF) description: 'Will not accept 2^32'.
38 tc deny: (wa accepts: 16r100000000) description: 'Accepted overlarge value'.
39 tc deny: (wa accepts: -1) description: 'Accepted negative number'.
42 tc@(UnitTests WordArray traits) endian
44 wale ::= WordArray LittleEndian new &capacity: 1.
45 wabe ::= WordArray BigEndian new &capacity: 1.
46 wale at: 0 put: 16r01020408.
47 wabe at: 0 put: 16r01020408.
48 tc assert: ((wale at: 0) = 16r01020408) description: 'Reading LittleEndian value failed'.
49 tc assert: ((wabe at: 0) = 16r01020408) description: 'Reading BigEndian value failed'.
50 tc assert: ((wale bytes at: 0) = 8) description: 'First LittleEndian byte wrong'.
51 tc assert: ((wale bytes at: 1) = 4) description: 'Second LittleEndian byte wrong'.
52 tc assert: ((wale bytes at: 2) = 2) description: 'Third LittleEndian byte wrong'.
53 tc assert: ((wale bytes at: 3) = 1) description: 'Forth LittleEndian byte wrong'.
54 tc assert: ((wabe bytes at: 0) = 1) description: 'First BigEndian byte wrong'.
55 tc assert: ((wabe bytes at: 1) = 2) description: 'Second BigEndian byte wrong'.
56 tc assert: ((wabe bytes at: 2) = 4) description: 'Third BigEndian byte wrong'.
57 tc assert: ((wabe bytes at: 3) = 8) description: 'Forth BigEndian byte wrong'.
60 tc@(UnitTests WordArray traits) do
64 wa ::= WordArray new &capacity: 12.
71 wa do: [|:each| sum: sum + each. counter: counter + 1].
72 tc assert: sum = 15 description: 'Sum of elements failed'.
73 tc assert: counter = 12 description: 'Count of elements failed'.
76 tc@(UnitTests WordArray traits) suite
77 [tc suiteForSelectors: {