diff options
author | TinWoodman92 <chrhodgden@gmail.com> | 2024-02-12 17:35:40 -0600 |
---|---|---|
committer | TinWoodman92 <chrhodgden@gmail.com> | 2024-02-12 17:35:40 -0600 |
commit | 30050fe873230690916d2c77fd5ad71cc92187c7 (patch) | |
tree | 197dab12840667314a04994fac95f2c079842fbf /test/unit_tests/binaryConverter.test.js | |
parent | c082e4ac4d98b755ced5b9ad9db2e64c9a85191a (diff) |
Adding more binary conversion tests
split static and dynamic testing
Diffstat (limited to 'test/unit_tests/binaryConverter.test.js')
-rw-r--r-- | test/unit_tests/binaryConverter.test.js | 50 |
1 files changed, 48 insertions, 2 deletions
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); + }); }); |