summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTinWoodman92 <chrhodgden@gmail.com>2024-02-12 17:35:40 -0600
committerTinWoodman92 <chrhodgden@gmail.com>2024-02-12 17:35:40 -0600
commit30050fe873230690916d2c77fd5ad71cc92187c7 (patch)
tree197dab12840667314a04994fac95f2c079842fbf
parentc082e4ac4d98b755ced5b9ad9db2e64c9a85191a (diff)
Adding more binary conversion tests
split static and dynamic testing
-rw-r--r--test/reports/coverage.txt18
-rw-r--r--test/unit_tests/binaryConverter.test.js50
2 files changed, 57 insertions, 11 deletions
diff --git a/test/reports/coverage.txt b/test/reports/coverage.txt
index 255fa17..56ff222 100644
--- a/test/reports/coverage.txt
+++ b/test/reports/coverage.txt
@@ -1,9 +1,9 @@
-------------------------|---------|----------|---------|---------|-------------------
-File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------------|---------|----------|---------|---------|-------------------
-All files | 67.76 | 100 | 65.62 | 68.1 |
- activationFunctions.js | 100 | 100 | 100 | 100 |
- binaryConverter.js | 97.29 | 100 | 90 | 97.22 | 45
- layer.js | 52.94 | 100 | 60 | 51.51 | 26-53
- nnetwork.js | 12 | 100 | 0 | 13.04 | 6-35
-------------------------|---------|----------|---------|---------|-------------------
+------------------------|---------|----------|---------|---------|----------------------
+File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
+------------------------|---------|----------|---------|---------|----------------------
+All files | 49.58 | 100 | 34.37 | 50.86 |
+ activationFunctions.js | 68 | 100 | 11.11 | 70.83 | 11,15,19,23,27,31,36
+ binaryConverter.js | 100 | 100 | 100 | 100 |
+ layer.js | 8.82 | 100 | 0 | 9.09 | 7-53
+ nnetwork.js | 12 | 100 | 0 | 13.04 | 6-35
+------------------------|---------|----------|---------|---------|----------------------
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);
+ });
});