Skip to content

Commit

Permalink
test for capacity constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
monmohan committed Oct 12, 2013
1 parent cbc44ff commit c2d3265
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/TestLinkedDeque.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,36 @@
ldq.offerLast(50);
ldq.push(60);
ldq.unshift(1);
assert.equal(ldq.size(),7);
console.log(ldq);
console.log(ldq.toArray());
assert.deepEqual(ldq.toArray(),[1, 40, 20, 30, 10, 50,60 ]);
assert.deepEqual(ldq.pop(),60);
assert.deepEqual(ldq.shift(),1);

}


function testCapacity(){
var ldq=new LinkedDeque(5);
ldq.offerFirst(10);
ldq.offerFirst(30);
ldq.offerFirst(20);
assert.equal(true,ldq.offerFirst(40));
assert.equal(true,ldq.offerLast(50));
assert.equal(false,ldq.push(60));
assert.equal(false,ldq.unshift(1));
assert.equal(ldq.size(),5);
console.log(ldq.toArray());
var sz=ldq.size();
while(sz>0){
ldq.pollFirst();
sz--;
}
console.log(ldq);

}
testBasic();
testCapacity();

}());

0 comments on commit c2d3265

Please sign in to comment.