Merge branch 'master' into vector-api
This commit is contained in:
@@ -10,10 +10,10 @@ describe('ol.structs.RBush', function() {
|
||||
|
||||
describe('when empty', function() {
|
||||
|
||||
describe('#all', function() {
|
||||
describe('#getAll', function() {
|
||||
|
||||
it('returns the expected number of objects', function() {
|
||||
expect(rBush.all()).to.be.empty();
|
||||
expect(rBush.getAll()).to.be.empty();
|
||||
});
|
||||
|
||||
});
|
||||
@@ -33,15 +33,15 @@ describe('ol.structs.RBush', function() {
|
||||
rBush.insert([-3, -3, -2, -2], objs[5]);
|
||||
});
|
||||
|
||||
describe('#allInExtent', function() {
|
||||
describe('#getAllInExtent', function() {
|
||||
|
||||
it('returns the expected objects', function() {
|
||||
var result;
|
||||
result = rBush.allInExtent([2, 2, 3, 3]);
|
||||
result = rBush.getAllInExtent([2, 2, 3, 3]);
|
||||
expect(result).to.contain(objs[1]);
|
||||
expect(result).to.contain(objs[2]);
|
||||
expect(result.length).to.be(2);
|
||||
result = rBush.allInExtent([-1, -1, 2, 2]);
|
||||
result = rBush.getAllInExtent([-1, -1, 2, 2]);
|
||||
expect(result).to.contain(objs[0]);
|
||||
expect(result).to.contain(objs[1]);
|
||||
expect(result).to.contain(objs[2]);
|
||||
@@ -50,22 +50,82 @@ describe('ol.structs.RBush', function() {
|
||||
});
|
||||
|
||||
it('returns an empty array when given a disjoint extent', function() {
|
||||
expect(rBush.allInExtent([5, 5, 6, 6]).length).to.be(0);
|
||||
expect(rBush.getAllInExtent([5, 5, 6, 6]).length).to.be(0);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#insert', function() {
|
||||
|
||||
it('throws an exception if called while iterating over all values',
|
||||
function() {
|
||||
expect(function() {
|
||||
rBush.forEach(function(value) {
|
||||
rBush.insert([0, 0, 1, 1], {});
|
||||
});
|
||||
}).to.throwException();
|
||||
});
|
||||
|
||||
it('throws an exception if called while iterating over an extent',
|
||||
function() {
|
||||
expect(function() {
|
||||
rBush.forEachInExtent([-10, -10, 10, 10], function(value) {
|
||||
rBush.insert([0, 0, 1, 1], {});
|
||||
});
|
||||
}).to.throwException();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#remove', function() {
|
||||
|
||||
it('can remove each object', function() {
|
||||
var i, ii;
|
||||
for (i = 0, ii = objs.length; i < ii; ++i) {
|
||||
expect(rBush.all()).to.contain(objs[i]);
|
||||
expect(rBush.getAll()).to.contain(objs[i]);
|
||||
rBush.remove(objs[i]);
|
||||
expect(rBush.all()).not.to.contain(objs[i]);
|
||||
expect(rBush.getAll()).not.to.contain(objs[i]);
|
||||
}
|
||||
});
|
||||
|
||||
it('throws an exception if called while iterating over all values',
|
||||
function() {
|
||||
expect(function() {
|
||||
rBush.forEach(function(value) {
|
||||
rBush.remove(value);
|
||||
});
|
||||
}).to.throwException();
|
||||
});
|
||||
|
||||
it('throws an exception if called while iterating over an extent',
|
||||
function() {
|
||||
expect(function() {
|
||||
rBush.forEachInExtent([-10, -10, 10, 10], function(value) {
|
||||
rBush.remove(value);
|
||||
});
|
||||
}).to.throwException();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#update', function() {
|
||||
|
||||
it('throws an exception if called while iterating over all values',
|
||||
function() {
|
||||
expect(function() {
|
||||
rBush.forEach(function(value) {
|
||||
rBush.update([0, 0, 1, 1], objs[1]);
|
||||
});
|
||||
}).to.throwException();
|
||||
});
|
||||
|
||||
it('throws an exception if called while iterating over an extent',
|
||||
function() {
|
||||
expect(function() {
|
||||
rBush.forEachInExtent([-10, -10, 10, 10], function(value) {
|
||||
rBush.update([0, 0, 1, 1], objs[1]);
|
||||
});
|
||||
}).to.throwException();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -84,12 +144,12 @@ describe('ol.structs.RBush', function() {
|
||||
}
|
||||
});
|
||||
|
||||
describe('#allInExtent', function() {
|
||||
describe('#getAllInExtent', function() {
|
||||
|
||||
it('returns the expected objects', function() {
|
||||
var i, ii;
|
||||
for (i = 0, ii = objs.length; i < ii; ++i) {
|
||||
expect(rBush.allInExtent(extents[i])).to.eql([objs[i]]);
|
||||
expect(rBush.getAllInExtent(extents[i])).to.eql([objs[i]]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -100,11 +160,11 @@ describe('ol.structs.RBush', function() {
|
||||
it('can remove each object in turn', function() {
|
||||
var i, ii;
|
||||
for (i = 0, ii = objs.length; i < ii; ++i) {
|
||||
expect(rBush.allInExtent(extents[i])).to.eql([objs[i]]);
|
||||
expect(rBush.getAllInExtent(extents[i])).to.eql([objs[i]]);
|
||||
rBush.remove(objs[i]);
|
||||
expect(rBush.allInExtent(extents[i])).to.be.empty();
|
||||
expect(rBush.getAllInExtent(extents[i])).to.be.empty();
|
||||
}
|
||||
expect(rBush.all()).to.be.empty();
|
||||
expect(rBush.getAll()).to.be.empty();
|
||||
});
|
||||
|
||||
it('can remove objects in random order', function() {
|
||||
@@ -118,11 +178,11 @@ describe('ol.structs.RBush', function() {
|
||||
}
|
||||
for (i = 0, ii = objs.length; i < ii; ++i) {
|
||||
var index = indexes[i];
|
||||
expect(rBush.allInExtent(extents[index])).to.eql([objs[index]]);
|
||||
expect(rBush.getAllInExtent(extents[index])).to.eql([objs[index]]);
|
||||
rBush.remove(objs[index]);
|
||||
expect(rBush.allInExtent(extents[index])).to.be.empty();
|
||||
expect(rBush.getAllInExtent(extents[index])).to.be.empty();
|
||||
}
|
||||
expect(rBush.all()).to.be.empty();
|
||||
expect(rBush.getAll()).to.be.empty();
|
||||
});
|
||||
|
||||
});
|
||||
@@ -141,18 +201,18 @@ describe('ol.structs.RBush', function() {
|
||||
}
|
||||
});
|
||||
|
||||
describe('#all', function() {
|
||||
describe('#getAll', function() {
|
||||
|
||||
it('returns the expected number of objects', function() {
|
||||
expect(rBush.all().length).to.be(1000);
|
||||
expect(rBush.getAll().length).to.be(1000);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#allInExtent', function() {
|
||||
describe('#getAllInExtent', function() {
|
||||
|
||||
it('returns the expected number of objects', function() {
|
||||
expect(rBush.allInExtent([0, 0, 10600, 10600]).length).to.be(1000);
|
||||
expect(rBush.getAllInExtent([0, 0, 10600, 10600]).length).to.be(1000);
|
||||
});
|
||||
|
||||
it('can perform 1000 in-extent searches', function() {
|
||||
@@ -163,7 +223,7 @@ describe('ol.structs.RBush', function() {
|
||||
var max = [min[0] + Math.random() * 500,
|
||||
min[1] + Math.random() * 500];
|
||||
var extent = [min[0], min[1], max[0], max[1]];
|
||||
n += rBush.allInExtent(extent).length;
|
||||
n += rBush.getAllInExtent(extent).length;
|
||||
}
|
||||
expect(n).not.to.be(0);
|
||||
});
|
||||
@@ -177,7 +237,7 @@ describe('ol.structs.RBush', function() {
|
||||
var max = [min[0] + Math.random() * 500,
|
||||
min[1] + Math.random() * 500];
|
||||
var extent = [min[0], min[1], max[0], max[1]];
|
||||
n += rBush.allInExtent(extent).length;
|
||||
n += rBush.getAllInExtent(extent).length;
|
||||
}
|
||||
expect(n).to.be(0);
|
||||
});
|
||||
@@ -195,7 +255,7 @@ describe('ol.structs.RBush', function() {
|
||||
var extent = [min[0], min[1], max[0], max[1]];
|
||||
rBush.insert(extent, {id: i});
|
||||
}
|
||||
expect(rBush.allInExtent([0, 0, 10600, 10600]).length).to.be(2000);
|
||||
expect(rBush.getAllInExtent([0, 0, 10600, 10600]).length).to.be(2000);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user