//typescriptClasses/Algorithms.ts //Matthew Ellison // Created: 10-19-20 //Modified: 10-19-20 //This class holds many algorithms that I have found it useful to keep around /* Copyright (C) 2020 Matthew Ellison This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ import assert = require("assert"); import { arrayEquals, getAllFib, getAllFibBig } from "./Algorithms"; function testGetAllFib(){ //Test 1 let correctAnswer = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]; let highestNumber = 100; let answer = getAllFib(highestNumber); assert.ok(arrayEquals(answer, correctAnswer), "getAllFib Integer 1 failed"); //Test 2 correctAnswer = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987] highestNumber = 1000; answer = getAllFib(highestNumber); assert.ok(arrayEquals(answer, correctAnswer), "getAllFib Integer 2 failed"); //Test 3 let bigCorrectAnswer = [BigInt(1), BigInt(1), BigInt(2), BigInt(3), BigInt(5), BigInt(8), BigInt(13), BigInt(21), BigInt(34), BigInt(55), BigInt(89)]; let bigHighestNumber = BigInt(100); let bigAnswer = getAllFibBig(bigHighestNumber); assert.ok(arrayEquals(bigAnswer, bigCorrectAnswer), "getAllFibBig failed"); console.log("testGetAllFib passed"); } //Run all of the tests testGetAllFib();