mirror of
https://bitbucket.org/Mattrixwv/typescriptclasses.git
synced 2025-12-06 18:33:59 -05:00
Created getAllFib() variants
This commit is contained in:
50
TestAlgorithms.ts
Normal file
50
TestAlgorithms.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
//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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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();
|
||||
Reference in New Issue
Block a user