From 60443c7effe51b6a677d8383a7e4896eff14aa3b Mon Sep 17 00:00:00 2001 From: malpotra <56645001+malpotra@users.noreply.github.com> Date: Sun, 22 Oct 2023 23:10:53 +0530 Subject: [PATCH] test: add tests for Binary Equivalent Algorithm (#1560) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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> --- Recursive/test/BinaryEquivalent.test.js | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Recursive/test/BinaryEquivalent.test.js diff --git a/Recursive/test/BinaryEquivalent.test.js b/Recursive/test/BinaryEquivalent.test.js new file mode 100644 index 000000000..b79a455ee --- /dev/null +++ b/Recursive/test/BinaryEquivalent.test.js @@ -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); + } + ) +})