Mise à jour de GitLab prévue ce dimanche 25 octobre 2020 à partir de 9h00 CEST | GitLab upgrade planned this Sunday 25rd of October 2020 from 9:00 AM CEST

Commit f587f5c7 authored by Éloïs's avatar Éloïs

[tests] add paths tests

parent 252a4597
Pipeline #1973 canceled with stage
in 1 minute and 15 seconds
"use strict";
const addon = require('./../lib/index');
const assert = require('assert');
const should = require('should');
let baseInstance
describe('Testing getPaths()', function() {
this.timeout(10000) // 10 seconds max for a test
before(() => {
baseInstance = addon.newMemoryInstance(3)
baseInstance.addNode()
baseInstance.addNode()
baseInstance.addNode()
baseInstance.addNode()
baseInstance.addLink(0, 1)
baseInstance.addLink(1, 2)
baseInstance.addLink(2, 3)
baseInstance.addLink(0, 3)
/**
* Wot:
*
* 0 --> 1 --> 2 --> 3
* `----------------^
*/
})
it('wotb.getPaths() should return arrays with the size of the paths', () => {
// Path 0 --> 1
assert.equal(baseInstance.getPaths(0, 1, 1).length, 1);
assert.equal(baseInstance.getPaths(0, 1, 1)[0].length, 2); // 0, 1
// Path 0 --> 2
assert.equal(baseInstance.getPaths(0, 2, 1).length, 0);
assert.equal(baseInstance.getPaths(0, 2, 2).length, 1);
assert.equal(baseInstance.getPaths(0, 2, 2)[0].length, 3); // 0, 1, 2
// Path 0 --> 3
assert.equal(baseInstance.getPaths(0, 3, 1).length, 1);
assert.equal(baseInstance.getPaths(0, 3, 1)[0].length, 2);
assert.equal(baseInstance.getPaths(0, 3, 2).length, 1);
assert.equal(baseInstance.getPaths(0, 3, 2)[0].length, 2);
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment