From e33503fc584bf9b16a68718ee3d760513d22227a Mon Sep 17 00:00:00 2001 From: Ankush263 <86042508+Ankush263@users.noreply.github.com> Date: Fri, 18 Mar 2022 13:57:40 +0530 Subject: [PATCH] merge: Add test case to DecimalToBinary,DecimalToOctal & OctToDecimal (#932) --- Conversions/test/DecimalToBinary.test.js | 26 ++++++++++++++++++++++++ Conversions/test/DecimalToOctal.test.js | 26 ++++++++++++++++++++++++ Conversions/test/OctToDecimal.test.js | 26 ++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 Conversions/test/DecimalToBinary.test.js create mode 100644 Conversions/test/DecimalToOctal.test.js create mode 100644 Conversions/test/OctToDecimal.test.js diff --git a/Conversions/test/DecimalToBinary.test.js b/Conversions/test/DecimalToBinary.test.js new file mode 100644 index 000000000..b3a26e1b7 --- /dev/null +++ b/Conversions/test/DecimalToBinary.test.js @@ -0,0 +1,26 @@ +import { decimalToBinary } from '../DecimalToBinary' + +test('The Binary representation of 35 is 100011', () => { + const res = decimalToBinary(35) + expect(res).toBe('100011') +}) + +test('The Binary representation of 1 is 1', () => { + const res = decimalToBinary(1) + expect(res).toBe('1') +}) + +test('The Binary representation of 1000 is 1111101000', () => { + const res = decimalToBinary(1000) + expect(res).toBe('1111101000') +}) + +test('The Binary representation of 2 is 10', () => { + const res = decimalToBinary(2) + expect(res).toBe('10') +}) + +test('The Binary representation of 17 is 10001', () => { + const res = decimalToBinary(17) + expect(res).toBe('10001') +}) diff --git a/Conversions/test/DecimalToOctal.test.js b/Conversions/test/DecimalToOctal.test.js new file mode 100644 index 000000000..0e4214b0c --- /dev/null +++ b/Conversions/test/DecimalToOctal.test.js @@ -0,0 +1,26 @@ +import { decimalToOctal } from '../DecimalToOctal' + +test('The Octal representation of 8 is 10', () => { + const res = decimalToOctal(8) + expect(res).toBe(10) +}) + +test('The Octal representation of 1 is 1', () => { + const res = decimalToOctal(1) + expect(res).toBe(1) +}) + +test('The Octal representation of 0 is 0', () => { + const res = decimalToOctal(0) + expect(res).toBe(0) +}) + +test('The Octal representation of 100 is 144', () => { + const res = decimalToOctal(100) + expect(res).toBe(144) +}) + +test('The Octal representation of 111 is 157', () => { + const res = decimalToOctal(111) + expect(res).toBe(157) +}) diff --git a/Conversions/test/OctToDecimal.test.js b/Conversions/test/OctToDecimal.test.js new file mode 100644 index 000000000..d36327508 --- /dev/null +++ b/Conversions/test/OctToDecimal.test.js @@ -0,0 +1,26 @@ +import { octalToDecimal } from '../OctToDecimal' + +test('The Decimal representation of Octal number 56 is 46', () => { + const res = octalToDecimal(56) + expect(res).toBe(46) +}) + +test('The Decimal representation of Octal number 99 is 81', () => { + const res = octalToDecimal(99) + expect(res).toBe(81) +}) + +test('The Decimal representation of Octal number 17 is 15', () => { + const res = octalToDecimal(17) + expect(res).toBe(15) +}) + +test('The Decimal representation of Octal number 100 is 64', () => { + const res = octalToDecimal(100) + expect(res).toBe(64) +}) + +test('The Decimal representation of Octal number 0 is 0', () => { + const res = octalToDecimal(0) + expect(res).toBe(0) +})