Skip to content

Commit 5bb8d96

Browse files
committed
Release 2.5.1
1 parent f32f39e commit 5bb8d96

File tree

5 files changed

+53
-10
lines changed

5 files changed

+53
-10
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ decode Mapcodes.
6161

6262
This produces the following help text:
6363

64-
MAPCODE (version 2.4.1)
64+
MAPCODE (version 2.5.1)
6565
Copyright (C) 2014-2016 Stichting Mapcode Foundation
6666

6767
Usage:
@@ -137,6 +137,10 @@ footprint, for example for embedded applications.
137137

138138
## Release Notes
139139

140+
### 2.5.1
141+
142+
* Updated unit test to compile with plain C and added some test cases.
143+
140144
### 2.5.0
141145

142146
* Added support for getting territory names in English and local alphabets.

mapcodelib/internal_alphabet_recognizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ static const signed char ALPHABET_OF[] = {
288288
#define ROMAN_VERSION_MAX_CHAR 0x3129
289289
static const char *ROMAN_VERSION_OF[] = {
290290
/* 0000 */ "\0 !?#$%&'()*+,-./0123456789:;<=>?",
291-
/* 0040 */ "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[?]^_`abcdefghijklmnopqrstuvwxyz{|}~?",
291+
/* 0040 */ "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[?]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~?",
292292
/* 0080 */ NULL,
293293
/* 00c0 */ NULL,
294294
/* 0100 */ NULL,

mapcodelib/mapcoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern "C" {
2525
#include "mapcode_alphabets.h"
2626

2727

28-
#define MAPCODE_C_VERSION "2.5.0"
28+
#define MAPCODE_C_VERSION "2.5.1"
2929
#define UWORD unsigned short int // 2-byte unsigned integer.
3030
#define MAX_NR_OF_MAPCODE_RESULTS 22 // Max. number of results ever returned by encoder (e.g. for 26.904899, 95.138515).
3131
#define MAX_PROPER_MAPCODE_LEN 11 // Max. number of characters in a proper mapcode (including the dot, excl. precision extension).

unittest/test_territories.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
// produced by fast_territories.cpp
18-
17+
// *** GENERATED FILE (fast_territories.cpp), DO NOT CHANGE OR PRETTIFY ***
1918
#include "../mapcodelib/mapcode_territories.h"
2019

2120
typedef struct {

unittest/unittest.c

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@
5050

5151
#include <pthread.h>
5252

53-
static const double METERS_PER_DEGREE_LAT = 110946.252133;
54-
static const double METERS_PER_DEGREE_LON = 111319.490793;
55-
5653
#define MAX_THREADS 16 // Optimal: not too much, approx. nr of cores * 2, better no more than 32.
5754
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
5855
#endif
@@ -1026,9 +1023,11 @@ static void testDistance(double d1, double d2) {
10261023

10271024

10281025
static int testDistances(void) {
1026+
static const double METERS_PER_DEGREE_LAT = 110946.252133;
1027+
static const double METERS_PER_DEGREE_LON = 111319.490793;
10291028
int nrTests = 0;
10301029
int i;
1031-
const double coordpairs[] = {
1030+
static const double coordpairs[] = {
10321031
// lat1, lon1, lat2, lon2, expected distance * 100000
10331032
1, 1, 1, 1, 0,
10341033
0, 0, 0, 1, 11131949079,
@@ -1380,6 +1379,7 @@ static int testCorrectDecode(char *mc, enum Territory tc) {
13801379
double lon1;
13811380
double lat2;
13821381
double lon2;
1382+
UWORD utf16[MAX_CLEAN_MAPCODE_LEN + 1];
13831383
int rc = decodeMapcodeToLatLonUtf8(&lat1, &lon1, mc, tc, NULL);
13841384
if (rc < 0) {
13851385
foundError();
@@ -1391,7 +1391,6 @@ static int testCorrectDecode(char *mc, enum Territory tc) {
13911391
printf("*** ERROR *** decodeMapcodeToLatLonUtf8 returns '%d' (should be 0) for mapcode='%s'\n", rc, mc);
13921392
}
13931393

1394-
UWORD utf16[MAX_CLEAN_MAPCODE_LEN + 1];
13951394
convertMapcodeToAlphabetUtf16(utf16, mc, ALPHABET_ARABIC);
13961395
rc = decodeMapcodeToLatLonUtf16(&lat2, &lon2, utf16, tc, NULL);
13971396
if (rc < 0) {
@@ -1876,6 +1875,33 @@ static int testAlphabets(void) {
18761875
int j;
18771876
const char *str, *expect;
18781877
static const char *TEST_PAIRS[] = {
1878+
"irl xx.xxxx", "IRL XX.XXXX", // Grid24
1879+
"cck XX.XX", "CCK XX.XX", // nameless22
1880+
"cze XX.XXX", "CZE XX.XXX", // nameless23
1881+
"NLD XXX.XX", "NLD XXX.XX", // nameless32
1882+
"VAT 5d.dd", "VAT 5D.DD", // Grid22
1883+
"NLD XX.XXX", "NLD XX.XXX", // Grid23
1884+
"bhr xxx.xx", "BHR XXX.XX", // Grid32
1885+
"FRA XXX.XXX", "FRA XXX.XXX", // Grid33
1886+
"irl xx.xxxx", "IRL XX.XXXX", // Grid24
1887+
"cub xxxx.xx", "CUB XXXX.XX", // Grid42
1888+
"ben xxxx.xxx", "BEN XXXX.XXX", // Grid34
1889+
"USA xxxx.xxxx", "USA XXXX.XXXX", // Grid44
1890+
"US-AZ hhh.hh", "US-AZ HHH.HH", // HGrid32
1891+
"Bel hhh.hhh", "BEL HHH.HHH", // HGrid33
1892+
"PAN hh.hhhh", "PAN HH.HHHH", // HGrid24
1893+
"GRC hhhh.hh", "GRC HHHH.HH", // HGrid42
1894+
"NZL hhhh.hhh", "NZL HHHH.HHH", // HGrid43
1895+
"KAZ hhh.hhhh", "KAZ HHH.HHHH", // HGrid34
1896+
"RUS xxxx.xxxx", "RUS XXXX.XXXX", // HGrid44
1897+
"CN-SH hhhh.hhhh", "CN-SH HHHH.HHHH", // HGrid44
1898+
"VAT hhhhh.hhhh", "VAT HHHHH.HHHH", // HGrid54
1899+
"hhhhh.hhhh", "HHHHH.HHHH", // HGrid54
1900+
"TUV hh.hhh", "TUV HH.HHH", // AutoHeader23
1901+
"LVA L88.ZVR", "LVA L88.ZVR", // AutoHeader33
1902+
"WLF XLG.3GP", "WLF XLG.3GP", // HGrid33 R
1903+
"VAT j0q3.27r", "VAT J0Q3.27R", // HGrid43 R
1904+
"PAK hhhh.hhhh", "PAK HHHH.HHHH", // HGrid44 R
18791905
"xxx.xxxx", "XXX.XXXX",
18801906
"nld XX.XX", "NLD XX.XX",
18811907
".123", "",
@@ -1944,6 +1970,20 @@ static int testAlphabets(void) {
19441970
str = TEST_PAIRS[j];
19451971
expect = TEST_PAIRS[j + 1];
19461972
convertMapcodeToAlphabetUtf16(enc, str, i);
1973+
{
1974+
char utf8[3 * MAX_MAPCODE_RESULT_LEN + 1];
1975+
MapcodeElements mapcodeElements;
1976+
double lat1, lon1, lat2, lon2, lat3, lon3;
1977+
convertMapcodeToAlphabetUtf8(utf8, str, i);
1978+
decodeMapcodeToLatLonUtf16(&lat1, &lon1, enc, TERRITORY_FRA, &mapcodeElements);
1979+
decodeMapcodeToLatLonUtf8(&lat2, &lon2, utf8, TERRITORY_FRA, &mapcodeElements);
1980+
decodeMapcodeToLatLonUtf8(&lat3, &lon3, str, TERRITORY_FRA, &mapcodeElements);
1981+
++nrTests;
1982+
if (lat1 != lat2 || lon1 != lon2 || lat1 != lat3 || lon1 != lon3) {
1983+
foundError();
1984+
printf("*** ERROR *** Difference in ascii/utf8/utf16 decoding %s\n", str);
1985+
}
1986+
}
19471987
myConvertToRoman(dec, enc);
19481988
++nrTests;
19491989
if (strcmp(dec, expect)) {

0 commit comments

Comments
 (0)