Skip to content

Commit

Permalink
Cleaned up unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
rijnb committed Oct 12, 2015
1 parent 6774d26 commit a8f5173
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 80 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@ of the Mapcode library by Rijn Buve and Matthew Lowden.

# Javascript Files for Mapcode Support

The following files provide the Javascript interfaces for mapcodes:

mapcode.js - Key routines for mapcode support
ndata.js - Data table for mapcode support

sample.html - Sample code to interpret / generate mapcodes
ctrynams.js - Optional js array with the names of territories (in English)

To run the Javascript unit tests, simply open the file `unittest/unittest/html`.

# Version History

* 2.2
* 2.2.0

Solved 1-microdegree gap in a few spots on Earth, noticable now extreme precision is possible;

Expand Down
8 changes: 4 additions & 4 deletions mapcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
*/
var entity_iso = [
'VAT','MCO','GIB','TKL','CCK','BLM','NRU','TUV','MAC','SXM',
'MAF','NFK','PCN','BVT','BMU','IOT','SMR','GGY','AIA','MSR',
Expand Down Expand Up @@ -116,11 +116,11 @@ var parents2 = "US,IN,CA,AU,MX,BR,RU,CN,";

var ccode_start = 112; // NLD
var mapcode_cversion = "2.0.2";
var mapcode_dataversion = "2.2";
var mapcode_dataversion = "2.2.0";

// *************************** mapcode_org *********************

var mapcode_javaversion = '2.2.1/Data' + mapcode_dataversion;
var mapcode_javaversion = '2.2.2/Data' + mapcode_dataversion;

/// PRIVATE returns string without leading spaces and plus-signs, and trailing spaces
function trim(str) {
Expand Down Expand Up @@ -670,7 +670,7 @@ function mzSetFromFractions(y, x, yDelta, xDelta) {
fmaxx: x + xDelta,
fminy: y + 1 + yDelta, // y+yDelta can NOT be represented
fmaxy: y + 1 // y CAN be represented
};
};
}
else {
return {
Expand Down
21 changes: 18 additions & 3 deletions unittest/test_encodes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright (C) 2014-2015 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

var testdata = [

Expand All @@ -22,14 +37,14 @@ var testdata = [
"", 55.015025, 20.950025, 0,0,
"", 21.6199995, -102.02419949999999, 0,0,
"", 21.6200035, -102.0242375, 0,0,
"", 29.727055, 73.87498650000001,0,0 ,
"", 29.727055, 73.87498650000001,0,0 ,
"", 29.727025, 73.87502499999999,0,0,
"", 28.679995, 78.71705600000000,0,0,
"", 28.680025, 78.71702500000001,0,0,
"", 5.785780,169.79175, 0,0 , // grid
"", -9.34015920,-171.99626665, 0,0 , // encompassing
"", 49.4632595, -2.55989, 0,0 , // inner grid
"", 49.4632625, -2.5599018, 0,0 , // old
"", 49.4632625, -2.5599018, 0,0 , // old
"", 47.1495405, 9.5319995, 0,0 , // inner grid AUT
"", 41.9035, 12.45200000000000 , 0,0,
"", 12.168921, -68.26226699999999, 0,0,
Expand Down Expand Up @@ -15883,6 +15898,6 @@ var testdata = [
"CN-XJ 123.XXX",46.1175215,84.492761000,3,7,
"CN-XJ 12.XXXX",45.925468,80.918028500,2,5,
"CN-XJ 0123.XX",40.917864,79.977318500,3,6,

-1];

15 changes: 15 additions & 0 deletions unittest/test_territories.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright (C) 2014-2015 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

function test_territories() {
test_territory("AAA", 533, 0, 0, 0);
Expand Down
Loading

0 comments on commit a8f5173

Please sign in to comment.