1
0
mirror of synced 2026-05-01 14:06:47 +00:00
Files
Interlisp.medley/internal/test/LANGUAGE/AUTO/17-3-ARRAY-ROW-MAJOR-INDEX.TEST

58 lines
2.0 KiB
Plaintext

;; Function To Be Tested: array-row-major-index
;;
;; Source: Common Lisp by Guy Steele
;; Section 17.3: Array Information Page: 293
;;
;; Created By: John Park
;;
;; Creation Date: June 10, 86
;;
;; Last Update:
;;
;; Filed as: {eris}<lispcore>cml>test>17-3-array-row-major-index.test
;;
;; Syntax: array-row-major-index array &rest subscripts
;;
;; Function Description: This function takes an array and valid subscripts
;; for the array and returns a single non-negative integer less than the
;; total size of the array that identifies the accessed element in the major
;; ordering of the elements. For a one-dimensional array, the result
;; of array-row-major-index always equals the supplied subscript.
;;
;; Argument(s): array and subscripts
;; Returns: non-negative integer
;;
;; Constraints/limitations: None
(do-test-group array-row-major-index-tests
:before (progn (setq array1 (make-array 10))
(setq array2 (make-array '(3 5)))
(setq array3 (make-array '(3 3 3)))
(setq array4 (make-array '(3 4 5 2))))
(do-test array-row-major-index-test
(and (eq (array-row-major-index array1 0) 0)
(eq (array-row-major-index array1 9) 9)
(eq (array-row-major-index array2 0 0) 0)
(eq (array-row-major-index array2 1 2) 7)
(eq (array-row-major-index array2 2 4) 14)
(eq (array-row-major-index array3 0 0 0) 0)
(eq (array-row-major-index array3 0 2 1) 7)
(eq (array-row-major-index array3 1 1 1) 13)
(eq (array-row-major-index array3 2 1 2) 23)
(eq (array-row-major-index array3 2 2 2) 26)
(eq (array-row-major-index array4 0 0 0 1) 1)
(eq (array-row-major-index array4 1 0 0 1) 41)
(eq (array-row-major-index array4 1 1 1 1) 53)
(or (< (array-row-major-index array4 2 3 2 1)
(array-total-size array4))
(>= (array-row-major-index array4 2 3 2 1) 0))
(or (< (array-row-major-index array4 2 1 4 0)
(array-total-size array4))
(>= (array-row-major-index array4 2 1 4 0) 0)))))
STOP