Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lesson_07/conditionals/src/lesson7.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
binarySearch,
compareStrings,
computeFactorial,
getFirstNFibonacciNumbers,
} from "./lesson7.js";

Expand Down Expand Up @@ -42,4 +43,20 @@ describe("Lesson7 Tests", () => {
// Test for value not present in the array
expect(binarySearch(values, 0, values.length - 1, 4)).toBe(-1);
});
test("testComputeFactorial", () => {
// Test for n = 0 (edge case)
expect(computeFactorial(0)).toBe(1);

// Test for n = 1
expect(computeFactorial(1)).toBe(1);

// Test for n = 5
expect(computeFactorial(5)).toBe(120);

// Test for n = 10
expect(computeFactorial(10)).toBe(3628800);

// Test for negative n (edge case)
expect(computeFactorial(-5)).toBe(0);
});
});
Loading