TL;DR
As with other data structures, common software bugs for Arrays are related to common Array operations. The post is aligned with the Black Box Software Testing Foundations course (BBST) designed by Rebecca Fiedler, Cem Kaner, and James Bach.
The array is a linear sequence of variables of the same type. For post What Every Programming Language Must Have I got a comment on Linkedin from Mirek Dlugosz:
“In this model, what is the difference between List and Array?”
List and Arrays are both collections of items. But Arrays are a collection of elements of the same type, and those elements are in memory ordered in a continuous linear sequence. Lists could mix element types, and elements are not placed in memory in a continuous sequence. Each element has a memory address pointer to the following element.
For example, Java has Arrays, but Python and Ruby do not.
Array usual notation is
a[ ]
and to get first element value
a[0]
Note that the index starts from 0. This is because the element index represents memory offset from the beginning of an array. The first element is at the beginning of the array.
It is interesting to see how we get the value of record attributes in the array. If a record has firstName attribute, for the second element, we get this value using the following notation:
a[1].firstName
Common operations on Arrays are:
- sort
- update
- read
- write
Common bugs with array are:
- Read-write past the end of the array – famous index out of bounds exception.
- Read the uninitialized array – Array does not have elements yet.
- Read/write the wrong element: an example is when we read first instead of the last element