/* eslint-env mocha */
const FenwickTree = require('../../src').DataStructures.FenwickTree;
const assert = require('assert');

describe('Fenwick Tree', () => {
  it('should be empty when initialized', () => {
    const inst = new FenwickTree([]);
    assert(inst.isEmpty());
    assert.equal(inst.size, 0);
  });

  it('should build tree with array', () => {
    const inst = new FenwickTree(4);

    inst.buildTree([1, 2, 3, 4]);
    assert(!inst.isEmpty());
    assert.equal(inst.size, 4);
  });

});

@@ -492,12 +492,299 @@
 %0A  %7D);%0A%0A
+  it('should sum the array till index', () =%3E %7B%0A    const inst = new FenwickTree(4);%0A%0A    inst.buildTree(%5B1, 2, 3, 4%5D);%0A%0A    assert.equal(inst.getSum(2), 6);%0A    assert.equal(inst.getSum(0), 1);%0A    assert.equal(inst.getSum(3), 10);%0A    assert.throws(() =%3E inst.getSum(4), Error);%0A  %7D);%0A
 %7D);%0A

Test Fenwick Tree: Sums till index