Created
August 21, 2022 06:53
-
-
Save hawaijar/e5be308261b30955feb45ce7134b1bad to your computer and use it in GitHub Desktop.
Test cases for Quick, Merge sorts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { quickSort, mergeSort } from "../index"; | |
describe("QuickSort Testing", () => { | |
it("should sort array[1,3,4,5,2,1]", () => { | |
const array = [1, 3, 4, 5, 2, 1]; | |
const sortedArray = array.sort((a, b) => a - b); | |
quickSort(array); | |
expect(array).toEqual(sortedArray); | |
}); | |
it("should sort array[5, 4, 3, 2, 1, 0]", () => { | |
const array = [5, 4, 3, 2, 1, 0]; | |
const sortedArray = array.sort((a, b) => a - b); | |
quickSort(array); | |
expect(array).toEqual(sortedArray); | |
}); | |
it("should sort array[-5, -4, -13, -2, -1, 10]", () => { | |
const array = [-5, -4, -13, -2, -1, 10]; | |
const sortedArray = array.sort((a, b) => a - b); | |
quickSort(array); | |
expect(array).toEqual(sortedArray); | |
}); | |
}); | |
describe("MergeSort Testing", () => { | |
it("should sort array[1,3,4,5,2,1]", () => { | |
const array = [1, 3, 4, 5, 2, 1]; | |
const sortedArray = array.sort((a, b) => a - b); | |
mergeSort(array); | |
expect(array).toEqual(sortedArray); | |
}); | |
it("should sort array[5, 4, 3, 2, 1, 0]", () => { | |
const array = [5, 4, 3, 2, 1, 0]; | |
const sortedArray = array.sort((a, b) => a - b); | |
mergeSort(array); | |
expect(array).toEqual(sortedArray); | |
}); | |
it("should sort array[-5, -4, -13, -2, -1, 10]", () => { | |
const array = [-5, -4, -13, -2, -1, 10]; | |
const sortedArray = array.sort((a, b) => a - b); | |
mergeSort(array); | |
expect(array).toEqual(sortedArray); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment