mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-22 12:01:15 -04:00
Fix the unit test of articles nearby (wrong target zone) : the algorithm seems ok, at least on this example
This commit is contained in:
parent
946a7f2d91
commit
d195cc9413
@ -276,6 +276,7 @@ define(function(require) {
|
|||||||
module("utils");
|
module("utils");
|
||||||
test("check reading an IEEE_754 float from 4 bytes" ,function() {
|
test("check reading an IEEE_754 float from 4 bytes" ,function() {
|
||||||
var byteArray = new Uint8Array(4);
|
var byteArray = new Uint8Array(4);
|
||||||
|
// This example is taken from https://fr.wikipedia.org/wiki/IEEE_754#Un_exemple_plus_complexe
|
||||||
// 1100 0010 1110 1101 0100 0000 0000 0000
|
// 1100 0010 1110 1101 0100 0000 0000 0000
|
||||||
byteArray[0] = 194;
|
byteArray[0] = 194;
|
||||||
byteArray[1] = 237;
|
byteArray[1] = 237;
|
||||||
@ -285,24 +286,34 @@ define(function(require) {
|
|||||||
equal(float, -118.625, "the IEEE_754 float should be converted as -118.625");
|
equal(float, -118.625, "the IEEE_754 float should be converted as -118.625");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
module("articles_nearby");
|
module("articles_nearby");
|
||||||
asyncTest("check articles found nearby France and Germany", function() {
|
asyncTest("check articles found nearby France and Germany", function() {
|
||||||
var callbackTitlesNearbyFound = function(titles) {
|
var callbackTitlesNearbyFound = function(titles) {
|
||||||
ok(titles !== null, "Some titles should be found");
|
ok(titles !== null, "Some titles should be found");
|
||||||
equal(titles.length, 3, "3 titles should be found");
|
equal(titles.length, 3, "3 titles should be found");
|
||||||
|
var titleDanube = null;
|
||||||
|
var titleParis = null;
|
||||||
var titleAlps = null;
|
var titleAlps = null;
|
||||||
for (var i=0; i<titles.length; i++) {
|
for (var i=0; i<titles.length; i++) {
|
||||||
var title = titles[i];
|
// TODO : read the titles instead of their position
|
||||||
if (title && title.name && title.name === "Alps") {
|
var titlepos = titles[i];
|
||||||
titleAlps = title;
|
if (titlepos === 6030) {
|
||||||
|
titleDanube = titlepos;
|
||||||
|
}
|
||||||
|
else if (titlepos === 18484) {
|
||||||
|
titleParis = titlepos;
|
||||||
|
}
|
||||||
|
else if (titlepos === 832) {
|
||||||
|
titleAlps = titlepos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ok(titleDanube !== null, "The title 'Danube' should be found");
|
||||||
|
ok(titleParis !== null, "The title 'Paris' should be found");
|
||||||
ok(titleAlps !== null, "The title 'Alps' should be found");
|
ok(titleAlps !== null, "The title 'Alps' should be found");
|
||||||
// TODO : check the coordinates of title Alps?
|
// TODO : check the title name and coordinates of each title (or at least one)
|
||||||
start();
|
start();
|
||||||
};
|
};
|
||||||
var rectFranceGermany = new geometry.rect(40,50,-10,10);
|
var rectFranceGermany = new geometry.rect(0,40,10,10);
|
||||||
localArchive.getTitlesInCoords(rectFranceGermany, 10, callbackTitlesNearbyFound);
|
localArchive.getTitlesInCoords(rectFranceGermany, 10, callbackTitlesNearbyFound);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user