From 30050fe873230690916d2c77fd5ad71cc92187c7 Mon Sep 17 00:00:00 2001 From: TinWoodman92 Date: Mon, 12 Feb 2024 17:35:40 -0600 Subject: Adding more binary conversion tests split static and dynamic testing --- test/unit_tests/binaryConverter.test.js | 50 +++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'test/unit_tests/binaryConverter.test.js') diff --git a/test/unit_tests/binaryConverter.test.js b/test/unit_tests/binaryConverter.test.js index 109dee1..62e60f5 100644 --- a/test/unit_tests/binaryConverter.test.js +++ b/test/unit_tests/binaryConverter.test.js @@ -3,7 +3,7 @@ const math = require('mathjs'); //import BinaryConverter from 'binaryConverter'; -describe('Test BinaryConversion module', () => { +describe('Static testing of BinaryConversion module', () => { let testConverter; let testVector; @@ -13,8 +13,25 @@ describe('Test BinaryConversion module', () => { testConverter = new BinaryConverter(2); testInteger = 2; testVector = math.matrix([1, 0]); + testResult = math.matrix([0, 0, 1, 0]); }); + test('test private key values from constructor', () => { + expect(testConverter._inputDigits).toEqual(2); + expect(testConverter._outputDigits).toEqual(4); + expect(testConverter._inputActivation).toEqual(math.matrix([0, 0])); + expect(testConverter._outputActivation).toEqual(math.matrix([1, 0, 0, 0])); + expect(testConverter._integer).toEqual(0); + }); + + test('test private key values from setting', () => { + testConverter.integer = testInteger; + expect(testConverter._inputDigits).toEqual(2); + expect(testConverter._outputDigits).toEqual(4); + expect(testConverter._inputActivation).toEqual(math.matrix([0, 0])); + expect(testConverter._outputActivation).toEqual(math.matrix([0, 0, 1, 0])); + expect(testConverter._integer).toEqual(2); + }); test('convert integer to binary array', () => { testConverter.integer = testInteger; @@ -26,7 +43,36 @@ describe('Test BinaryConversion module', () => { expect(testConverter.integer).toEqual(testInteger); }); - test.todo('Random array initializes correct integer'); + test('output activation', () => { + testConverter.inputActivation = testVector; + expect(testConverter.outputActivation).toEqual(testResult); + }); + +}); + +describe('Dynamic testing of BinaryConversion module', () => { + + let testConverter; + let testVector; + let testInteger; + + beforeEach(() => { + testConverter = new BinaryConverter(2); + testInteger = 2; + testVector = math.matrix([1, 0]); + }); + + test('Random array returns and sets same vector', () => { + testVector = testConverter.randomInput(); + expect(testConverter.inputActivation).toEqual(testVector); + }); + + test('Random array initializes correct integer', () => { + testVector = testConverter.randomInput(); + testInteger = testConverter.integer + testConverter.inputActivation = testVector; + expect(testConverter.integer).toEqual(testInteger); + }); }); -- cgit v1.2.3