2023-07-10 05:56:26 +00:00
|
|
|
const JsUnit = imports.jsUnit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Asserts if two arrays have the same length and each element passes assertEquals
|
|
|
|
*
|
|
|
|
* @template T
|
|
|
|
* @param {string} errorMessage an error message if the arrays are not equal
|
|
|
|
* @param {T[]} array1 the first array
|
|
|
|
* @param {T[]} array2 the second array
|
|
|
|
*/
|
2023-07-10 05:19:40 +00:00
|
|
|
export function assertArrayEquals(errorMessage, array1, array2) {
|
2023-07-10 05:56:26 +00:00
|
|
|
JsUnit.assertEquals(`${errorMessage} length`, array1.length, array2.length);
|
|
|
|
for (let j = 0; j < array1.length; j++)
|
|
|
|
JsUnit.assertEquals(`${errorMessage} item ${j}`, array1[j], array2[j]);
|
|
|
|
}
|