initial commit

This commit is contained in:
Mahdi Dibaiee
2015-07-24 11:14:18 +04:30
commit a7e7ca0350
916 changed files with 101220 additions and 0 deletions

View File

@ -0,0 +1,11 @@
import chai from 'chai';
import {Node, List} from '../linked-lists';
chai.should();
test('Constructing new Lists', () => {
let list = new List(new Node(10, new Node(5)));
list.root.value.should.equal(10);
list.root.next.value.should.equal(5);
});

View File

@ -0,0 +1,38 @@
import chai from 'chai';
import {Node, Trie} from '../trie';
chai.should();
test('Construct new Trie', () => {
let trie = new Trie();
trie.root.children.length.should.equal(0);
});
test('Add new parent values', () => {
let trie = new Trie();
trie.add('a');
trie.add('b');
trie.add('c');
trie.add('t');
trie.root.children.length.should.equal(4);
});
test('Adding values with existing parents', () => {
let trie = new Trie();
trie.add('a');
trie.add('ab');
trie.add('aba');
trie.add('abas');
let parent = trie.root;
for (let i = 0; i < 3; i++) {
parent.children.length.should.equal(1);
parent = parent.children[0];
}
parent.children.length.should.equal(0);
});