mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
test: add tests for Binary Equivalent Algorithm (#1560)
* test: add tests for Binary Equivalent Algorithm * test: Refactored tests using .each() * Update BinaryEquivalent.test.js --------- Co-authored-by: {Harshit Malpotra} <{malpotra.harshit@gmail.com}> Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com>
This commit is contained in:
29
Recursive/test/BinaryEquivalent.test.js
Normal file
29
Recursive/test/BinaryEquivalent.test.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { binaryEquivalent } from "../BinaryEquivalent";
|
||||||
|
|
||||||
|
const tests = [
|
||||||
|
{
|
||||||
|
test: 2,
|
||||||
|
expectedValue: "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: 0,
|
||||||
|
expectedValue: "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: 543,
|
||||||
|
expectedValue: "1000011111"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: 4697621023,
|
||||||
|
expectedValue: "100011000000000000000001000011111"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
describe("Binary Equivalent", () => {
|
||||||
|
test.each(tests)(
|
||||||
|
"of $test should be $expectedValue",
|
||||||
|
({test, expectedValue}) => {
|
||||||
|
expect(binaryEquivalent(test)).toBe(expectedValue);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
Reference in New Issue
Block a user