Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

tree-layout-tester

mikolalysenko41MIT0.0.4

Tests cases for various tree layout algorithms

tree, layout, balanced, binary, search, algorithms, data, structures

readme

tree-layout-tester

Checks a tree layout produces results consistent with a known tree ordering

Install

npm install tree-layout-tester

Example

var layoutTester = require("tree-layout-tester")

//Your tree layout
var myLayout =  // ...  something

require("tap").test("my layout test", function(t) {

  var T = layoutTester.T
    , testTree = layoutTester.bind({}, t, myLayout)

  //Enforce that tree layout respects this ordering
  testTree(T(0, T(1), T(2))

  t.end()
})

API

require("tree-layout-tester").T(v, left, right)

Creates a tree with index v and the given left/right subtrees

require("tree-layout-tester")(tap, layout, root)

Tests the layout against the tree given by root. tap is a pointer to a tap object.

License

(c) 2013 Mikola Lysenko. MIT License