Skip to content

Commit

Permalink
[COMMIT] [queues.js] Adding tests for Queues, QueueTop, QueueBottom, …
Browse files Browse the repository at this point in the history
…Stack, Priority, Double. Removing Base and BaseLowFootPrint from the exports. Difficult to manage without understanding the class logic extension, type, method, offset, endOffset variables. TODO: Circular, Semaphore.
  • Loading branch information
Ganesh K Bhat committed Feb 4, 2023
1 parent a793e69 commit 833b6ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
10 changes: 6 additions & 4 deletions demos/demos.double.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@

var Queue = require("../index.js").DoubleEnded;

let type = "front";
let method = "fifo";

var queue = new Queue();
var queue = new Queue(type, method);
queue.insertFront(1);
queue.insertFront(2);
queue.insertFront(3);
Expand All @@ -39,7 +41,7 @@ console.log("queue.size()", queue.size());
console.log("queue.toArray()", queue.toArray());


queue = new Queue();
queue = new Queue(type, method);
queue.insertFront(1);
queue.insertFront(2);
queue.insertFront(3);
Expand All @@ -60,7 +62,7 @@ console.log("queue.size()", queue.size());
console.log("queue.toArray()", queue.toArray());


queue = new Queue();
queue = new Queue(type, method);
queue.insertLast(1);
queue.insertLast(2);
queue.insertLast(3);
Expand All @@ -81,7 +83,7 @@ console.log("queue.size()", queue.size());
console.log("queue.toArray()", queue.toArray());


queue = new Queue();
queue = new Queue(type, method);
queue.insertLast(1);
queue.insertLast(2);
queue.insertLast(3);
Expand Down
14 changes: 13 additions & 1 deletion test/demos.double.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,23 @@ describe('test-.mjs::queues.js: Test Suite for queues.js demos.double.js Files',
expect(queue.toArray().length).to.equal(8);

expect(queue.deleteLast()).to.equal(1);
expect(queue.deleteFront()).to.equal(8);
expect(queue.deleteLast()).to.equal(2);

expect(queue.size()).to.equal(6);
expect(queue.toArray().length).to.equal(8);

expect(queue.deleteLast()).to.equal(3);
expect(queue.deleteLast()).to.equal(4);

expect(queue.size()).to.equal(4);
expect(queue.toArray().length).to.equal(8);

expect(queue.deleteFront()).to.equal(8);
expect(queue.deleteFront()).to.equal(7);

expect(queue.size()).to.equal(2);
expect(queue.toArray().length).to.equal(8);

done();
});

Expand Down

0 comments on commit 833b6ba

Please sign in to comment.