@@ -164,6 +164,25 @@ CTArray2DTest >> testCannotAccessWithWrongCoordinates [
164164 self should: [ self arrayClass width2Height3 atColumn: 6 atRow: 1 ] raise: SubscriptOutOfBounds
165165]
166166
167+ { #category : ' tests' }
168+ CTArray2DTest >> testColumns [
169+ | foo |
170+ foo := self arrayClass width2Height3.
171+ self assert: foo columns equals: #(#(1 3 5) #(2 4 6) )
172+ ]
173+
174+ { #category : ' tests' }
175+ CTArray2DTest >> testColumnsDo [
176+ | foo array columnIndex |
177+ foo := self arrayClass width2Height3.
178+ array := Array new : 2 .
179+ columnIndex := 1 .
180+ foo columnsDo: [ :column |
181+ array at: columnIndex put: column.
182+ columnIndex := columnIndex + 1 ].
183+ self assert: array equals: #(#(1 3 5) #(2 4 6) )
184+ ]
185+
167186{ #category : ' tests-copying' }
168187CTArray2DTest >> testCopy [
169188 | foo cop |
@@ -239,6 +258,78 @@ CTArray2DTest >> testFromArray [
239258
240259]
241260
261+ { #category : ' tests-enumeration' }
262+ CTArray2DTest >> testFromBottomToTopFromLeftToRightDo [
263+ |foo res |
264+ foo := self arrayClass width2Height3.
265+ res := OrderedCollection new .
266+ foo fromBottomToTopFromLeftToRightDo: [ :each | res add: each ].
267+ self assert: res equals: #(5 3 1 6 4 2) asOrderedCollection
268+ ]
269+
270+ { #category : ' tests-enumeration' }
271+ CTArray2DTest >> testFromBottomToTopFromRightToLeftDo [
272+ |foo res |
273+ foo := self arrayClass width2Height3.
274+ res := OrderedCollection new .
275+ foo fromBottomToTopFromRightToLeftDo: [ :each | res add: each ].
276+ self assert: res equals: #(6 4 2 5 3 1) asOrderedCollection
277+ ]
278+
279+ { #category : ' tests-enumeration' }
280+ CTArray2DTest >> testFromLeftToRightFromBottomToTopDo [
281+ |foo res |
282+ foo := self arrayClass width2Height3.
283+ res := OrderedCollection new .
284+ foo fromLeftToRightFromBottomToTopDo: [ :each | res add: each ].
285+ self assert: res equals: #(5 6 3 4 1 2) asOrderedCollection
286+ ]
287+
288+ { #category : ' tests-enumeration' }
289+ CTArray2DTest >> testFromLeftToRightFromTopToBottomDo [
290+ |foo res |
291+ foo := self arrayClass width2Height3.
292+ res := OrderedCollection new .
293+ foo fromLeftToRightFromTopToBottomDo: [ :each | res add: each ].
294+ self assert: res equals: #(1 2 3 4 5 6) asOrderedCollection
295+ ]
296+
297+ { #category : ' tests-enumeration' }
298+ CTArray2DTest >> testFromRightToLeftFromBottomToTopDo [
299+ |foo res |
300+ foo := self arrayClass width2Height3.
301+ res := OrderedCollection new .
302+ foo fromRightToLeftFromBottomToTopDo: [ :each | res add: each ].
303+ self assert: res equals: #(6 5 4 3 2 1) asOrderedCollection
304+ ]
305+
306+ { #category : ' tests-enumeration' }
307+ CTArray2DTest >> testFromRightToLeftFromTopToBottomDo [
308+ |foo res |
309+ foo := self arrayClass width2Height3.
310+ res := OrderedCollection new .
311+ foo fromRightToLeftFromTopToBottomDo: [ :each | res add: each ].
312+ self assert: res equals: #(2 1 4 3 6 5) asOrderedCollection
313+ ]
314+
315+ { #category : ' tests-enumeration' }
316+ CTArray2DTest >> testFromTopToBottomFromLeftToRightDo [
317+ |foo res |
318+ foo := self arrayClass width2Height3.
319+ res := OrderedCollection new .
320+ foo fromTopToBottomFromLeftToRightDo: [ :each | res add: each ].
321+ self assert: res equals: #(1 3 5 2 4 6) asOrderedCollection
322+ ]
323+
324+ { #category : ' tests-enumeration' }
325+ CTArray2DTest >> testFromTopToBottomFromRightToLeftDo [
326+ |foo res |
327+ foo := self arrayClass width2Height3.
328+ res := OrderedCollection new .
329+ foo fromTopToBottomFromRightToLeftDo: [ :each | res add: each ].
330+ self assert: res equals: #(2 4 6 1 3 5) asOrderedCollection
331+ ]
332+
242333{ #category : ' tests-accessing' }
243334CTArray2DTest >> testHeight [
244335
@@ -253,17 +344,6 @@ CTArray2DTest >> testIndexXY [
253344 self assert: (foo indexX: 2 y: 3 ) equals: (3 - 1 )* (foo width)+ 2
254345]
255346
256- { #category : ' tests' }
257- CTArray2DTest >> testLeftToRightFromBottomToTopDo [
258-
259- | a2d res |
260- a2d := CTArray2D fromArray: #(1 2 3 4 5 6) width: 3 .
261- res := OrderedCollection new .
262- a2d leftToRightFromBottomToTopDo: [ :each | res add: each ].
263- self assert: res equals: #(4 5 6 1 2 3 ) asOrderedCollection
264-
265- ]
266-
267347{ #category : ' tests-accessing' }
268348CTArray2DTest >> testNeighborsAtColumnAtRow [
269349
0 commit comments