[api] doing this now since we're bumping a major version. Using a libpostal prefixes for all public header functions and definitions

This commit is contained in:
Al
2017-03-31 03:35:51 -04:00
parent f8d7bdf364
commit 6d4c7984df
16 changed files with 184 additions and 201 deletions

View File

@@ -8,9 +8,9 @@
SUITE(libpostal_expansion_tests);
static greatest_test_res test_expansion_contains(char *input, char *output, normalize_options_t options) {
static greatest_test_res test_expansion_contains(char *input, char *output, libpostal_normalize_options_t options) {
size_t num_expansions;
char **expansions = expand_address(input, options, &num_expansions);
char **expansions = libpostal_expand_address(input, options, &num_expansions);
bool contains_expansion = false;
char *expansion;
@@ -23,6 +23,8 @@ static greatest_test_res test_expansion_contains(char *input, char *output, norm
}
libpostal_expansion_array_destroy(expansions, num_expansions);
if (!contains_expansion) {
printf("Expansions should contain %s, got {", output);
for (size_t i = 0; i < num_expansions; i++) {
@@ -36,7 +38,7 @@ static greatest_test_res test_expansion_contains(char *input, char *output, norm
PASS();
}
static greatest_test_res test_expansion_contains_with_languages(char *input, char *output, normalize_options_t options, size_t num_languages, ...) {
static greatest_test_res test_expansion_contains_with_languages(char *input, char *output, libpostal_normalize_options_t options, size_t num_languages, ...) {
char **languages = NULL;
size_t i;
@@ -50,7 +52,7 @@ static greatest_test_res test_expansion_contains_with_languages(char *input, cha
for (i = 0; i < num_languages; i++) {
lang = va_arg(args, char *);
ASSERT(strlen(lang) < MAX_LANGUAGE_LEN);
ASSERT(strlen(lang) < LIBPOSTAL_MAX_LANGUAGE_LEN);
languages[i] = strdup(lang);
}
@@ -75,7 +77,7 @@ static greatest_test_res test_expansion_contains_with_languages(char *input, cha
TEST test_expansions(void) {
normalize_options_t options = get_libpostal_default_options();
libpostal_normalize_options_t options = libpostal_get_default_options();
CHECK_CALL(test_expansion_contains_with_languages("123 Main St. #2f", "123 main street number 2f", options, 1, "en"));
CHECK_CALL(test_expansion_contains_with_languages("S St. NW", "s street northwest", options, 1, "en"));
@@ -86,7 +88,7 @@ TEST test_expansions(void) {
}
TEST test_expansions_language_classifier(void) {
normalize_options_t options = get_libpostal_default_options();
libpostal_normalize_options_t options = libpostal_get_default_options();
CHECK_CALL(test_expansion_contains_with_languages("V XX Sett", "via 20 settembre", options, 0, NULL));
CHECK_CALL(test_expansion_contains_with_languages("C/ Ocho", "calle 8", options, 0, NULL));
@@ -94,7 +96,7 @@ TEST test_expansions_language_classifier(void) {
}
TEST test_expansions_no_options(void) {
normalize_options_t options = get_libpostal_default_options();
libpostal_normalize_options_t options = libpostal_get_default_options();
options.lowercase = false;
options.latin_ascii = false;
options.transliterate = false;

View File

@@ -14,8 +14,8 @@ typedef struct labeled_component {
char *component;
} labeled_component_t;
static greatest_test_res test_parse_result_equals(char *input, address_parser_options_t options, size_t output_len, ...) {
address_parser_response_t *response = parse_address(input, options);
static greatest_test_res test_parse_result_equals(char *input, libpostal_address_parser_options_t options, size_t output_len, ...) {
libpostal_address_parser_response_t *response = libpostal_parse_address(input, options);
va_list args;
@@ -56,11 +56,11 @@ static greatest_test_res test_parse_result_equals(char *input, address_parser_op
printf("%s: %s\n", response->labels[i], response->components[i]);
}
va_end(args);
address_parser_response_destroy(response);
libpostal_address_parser_response_destroy(response);
FAIL();
}
address_parser_response_destroy(response);
libpostal_address_parser_response_destroy(response);
PASS();
}
@@ -68,7 +68,7 @@ static greatest_test_res test_parse_result_equals(char *input, address_parser_op
TEST test_us_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
"Black Alliance for Just Immigration 660 Nostrand Ave, Brooklyn, N.Y., 11216",
@@ -631,7 +631,7 @@ TEST test_us_parses(void) {
}
TEST test_ca_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
// From: https://github.com/openvenues/libpostal/issues/55
@@ -694,7 +694,7 @@ TEST test_ca_parses(void) {
}
TEST test_jm_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
// From https://github.com/openvenues/libpostal/issues/113
@@ -730,7 +730,7 @@ TEST test_jm_parses(void) {
TEST test_gb_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
@@ -1069,7 +1069,7 @@ TEST test_gb_parses(void) {
}
TEST test_im_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
// Multiple house names
@@ -1089,7 +1089,7 @@ TEST test_im_parses(void) {
}
TEST test_nz_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
"wellington new zealand",
@@ -1103,7 +1103,7 @@ TEST test_nz_parses(void) {
}
TEST test_fr_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
// From https://github.com/pelias/pelias/issues/426
"Chambéry",
@@ -1169,7 +1169,7 @@ TEST test_fr_parses(void) {
TEST test_es_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
// Use Spanish toponym
CHECK_CALL(test_parse_result_equals(
@@ -1214,7 +1214,7 @@ TEST test_es_parses(void) {
}
TEST test_co_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
"Cra 18#63-64 B Chapinero Bogotá DC Colombia",
@@ -1277,7 +1277,7 @@ TEST test_co_parses(void) {
}
TEST test_mx_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
// From: https://github.com/openvenues/libpostal/issues/126
CHECK_CALL(test_parse_result_equals(
@@ -1309,7 +1309,7 @@ TEST test_mx_parses(void) {
TEST test_br_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
// Brazil address with sem número (s/n) and CEP used with postal code
@@ -1328,7 +1328,7 @@ TEST test_br_parses(void) {
}
TEST test_cn_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
// From https://github.com/openvenues/libpostal/issues/71
@@ -1351,7 +1351,7 @@ TEST test_cn_parses(void) {
TEST test_jp_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
// Example of a Kanji address
@@ -1410,7 +1410,7 @@ TEST test_jp_parses(void) {
}
TEST test_kr_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
// English/Romanized Korean, ro + gil address, English unit
@@ -1429,7 +1429,7 @@ TEST test_kr_parses(void) {
}
TEST test_my_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
// From https://github.com/openvenues/libpostal/issues/121
@@ -1448,7 +1448,7 @@ TEST test_my_parses(void) {
}
TEST test_za_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
// Contains HTML entity which should be normalized
@@ -1469,7 +1469,7 @@ TEST test_za_parses(void) {
}
TEST test_de_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
/* Contains German concatenated street suffix
@@ -1518,7 +1518,7 @@ TEST test_de_parses(void) {
TEST test_at_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
"Eduard Sueß Gasse 9",
@@ -1592,7 +1592,7 @@ TEST test_at_parses(void) {
TEST test_nl_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
// From: https://github.com/openvenues/libpostal/issues/162
"Nieuwe Binnenweg 17-19, Oude Westen, Rotterdam NL",
@@ -1637,7 +1637,7 @@ TEST test_nl_parses(void) {
}
TEST test_da_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
"Valdemarsgade 42 4 t.v. København, 1665 Danmark",
@@ -1655,7 +1655,7 @@ TEST test_da_parses(void) {
}
TEST test_fi_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
"1 Hämeenkatu, Tampere, Finland",
@@ -1679,7 +1679,7 @@ TEST test_fi_parses(void) {
}
TEST test_no_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
// From: https://github.com/openvenues/libpostal/issues/39#issuecomment-221027220
@@ -1696,7 +1696,7 @@ TEST test_no_parses(void) {
}
TEST test_se_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
// Uses the "en trappa upp" (one floor up) form in Swedish addresses
@@ -1714,7 +1714,7 @@ TEST test_se_parses(void) {
}
TEST test_hu_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
// Hungarian, 4-digit postal code
@@ -1730,7 +1730,7 @@ TEST test_hu_parses(void) {
}
TEST test_ro_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
// Romanian address with staircase
@@ -1751,7 +1751,7 @@ TEST test_ro_parses(void) {
TEST test_ru_parses(void) {
address_parser_options_t options = get_libpostal_address_parser_default_options();
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
CHECK_CALL(test_parse_result_equals(
// Contains Cyrillic with abbreviations