From e830fc25d891b4c186f96ec584cdc8ed4f261e31 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Tue, 7 Apr 2015 11:09:23 +0900 Subject: [PATCH] uniname/uniname-tests: fix failure due to alias Reported by Jack Howarth in: . * tests/uniname/test-uninames.c (name_has_alias): New function. (test_inverse_lookup): Exclude character name with valid alias, from randomly generated character names. (main): Fill unicode_aliases before calling test functions. --- ChangeLog | 10 ++++++++++ tests/uniname/test-uninames.c | 18 ++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2cf42d263d..bca02d7196 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2015-04-07 Daiki Ueno + + uniname/uniname-tests: fix failure due to alias + Reported by Jack Howarth in: + . + * tests/uniname/test-uninames.c (name_has_alias): New function. + (test_inverse_lookup): Exclude character name with valid alias, + from randomly generated character names. + (main): Fill unicode_aliases before calling test functions. + 2015-04-03 Giuseppe Scrivano hash: remove deprecated hash_insert0 function diff --git a/tests/uniname/test-uninames.c b/tests/uniname/test-uninames.c index eccf2f4ec0..e4435e61f0 100644 --- a/tests/uniname/test-uninames.c +++ b/tests/uniname/test-uninames.c @@ -181,6 +181,16 @@ fill_aliases (const char *namealiases_filename) } } +static int +name_has_alias (unsigned int uc) +{ + int i; + for (i = 0; i < ALIASLEN; i++) + if (unicode_aliases[i].uc == uc) + return 1; + return 0; +} + /* Perform an exhaustive test of the unicode_character_name function. */ static int test_name_lookup () @@ -296,6 +306,7 @@ test_inverse_lookup () result = unicode_name_character (buf); if (result != UNINAME_INVALID + && !name_has_alias (result) && !(unicode_names[result] != NULL && strcmp (unicode_names[result], buf) == 0)) { @@ -354,15 +365,14 @@ main (int argc, char *argv[]) set_program_name (argv[0]); fill_names (argv[1]); + if (argc > 2) + fill_aliases (argv[2]); error |= test_name_lookup (); error |= test_inverse_lookup (); if (argc > 2) - { - fill_aliases (argv[2]); - error |= test_alias_lookup (); - } + error |= test_alias_lookup (); return error; } -- 2.39.5