import { indicesInTable, indicesOf, initializePointerTable, initializeTable, lastColumnOf, lastRowOf } from "../src/Table" import { TripleTable } from "../src/types" describe('initializeTable', function() { it('creates a table filled with a given value', function() { let table: number[][] = initializeTable(10, 10, 1) expect(table.length).toEqual(10) expect(table[2][3]).toEqual(1) }) }) describe('indicesOf', function() { it('finds the indices of a given search value', function () { let arr = [0, 4, 8, 4, 0] let indices = indicesOf(arr, 4) expect(indices).toEqual([1, 3]) }) }) describe('lastColumn', function () { it ('returns the last column of a table', function () { let table = [[0, 0, 1], [0, 0, 2], [0, 0, 3]] expect(lastColumnOf(table)).toEqual([1, 2, 3]) }) }) describe('lastRow', function () { it ('returns the last row of a table', function () { let table = [[0, 0, 0], [0, 0, 0], [1, 2, 3]] expect(lastRowOf(table)).toEqual([1, 2, 3]) }) }) describe('indicesInTable', function () { it ('finds the positions of a given value in a table', function () { let table = [[0, 0, 0], [0, 2, 0], [0, 1, 2]] expect(indicesInTable(table, 2)).toEqual([[1, 1], [2, 2]]) }) }) describe('initializePointerTable', function () { it ('initializes a pointer table', function() { let table: TripleTable = initializePointerTable(10, 10) expect(table[3][0]).toEqual([0, 0, 1]) expect(table[0][3]).toEqual([1, 0, 0]) expect(table[0][0]).toEqual([0, 0, 0]) }) })