-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: updated CONTRIBUTING.md and added test cases for Moore Voting Al…
…gorithm
- Loading branch information
Mrinal Chauhan
committed
Oct 24, 2024
1 parent
448415c
commit 193763d
Showing
7 changed files
with
39 additions
and
42 deletions.
There are no files selected for viewing
Empty file.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import {MooreVotingAlgorithm} from "../MooreVotingAlgorithm"; | ||
import { MooreVotingAlgorithm } from '../MooreVotingAlgorithm' | ||
describe('Moore Voting Algorithm', () => { | ||
it.each([ | ||
[[1, 1, 2, 1, 3, 1, 1], 1], // Majority element 1 | ||
[[1, 2, 3, 4], null], // No majority element | ||
[[2, 2, 2, 2, 5, 5, 5, 2], 2], // Majority element 2 | ||
[[], null], // Empty array, no majority | ||
[[3], 3] // Single element, it's the majority | ||
])('returns %j when given %j', (array, expected) => { | ||
expect(MooreVotingAlgorithm(array)).toEqual(expected); | ||
}); | ||
}); | ||
it.each([ | ||
[[1, 1, 2, 1, 3, 1, 1], 1], // Majority element 1 | ||
[[2, 2, 2, 2, 5, 5, 5, 2], 2], // Majority element 2 | ||
[[3], 3], // Single element, it's the majority | ||
[[1, 2, 3, 4, 5, 6, 7], null] // No majority element in the array | ||
])('returns %j when given %j', (array, expected) => { | ||
expect(MooreVotingAlgorithm(array)).toEqual(expected) | ||
}) | ||
}) |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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