changeset 17953:d1b79c99331f

uniname/uniname-tests: fix failure due to alias Reported by Jack Howarth in: <https://lists.gnu.org/archive/html/bug-libunistring/2015-04/msg00000.html>. * 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.
author Daiki Ueno <ueno@gnu.org>
date Tue, 07 Apr 2015 11:09:23 +0900
parents 522f6f858b0c
children 65f6122c1b68
files ChangeLog tests/uniname/test-uninames.c
diffstat 2 files changed, 24 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Apr 03 14:58:12 2015 +0100
+++ b/ChangeLog	Tue Apr 07 11:09:23 2015 +0900
@@ -1,3 +1,13 @@
+2015-04-07  Daiki Ueno  <ueno@gnu.org>
+
+	uniname/uniname-tests: fix failure due to alias
+	Reported by Jack Howarth in:
+	<https://lists.gnu.org/archive/html/bug-libunistring/2015-04/msg00000.html>.
+	* 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  <gscrivan@redhat.com>
 
 	hash: remove deprecated hash_insert0 function
--- a/tests/uniname/test-uninames.c	Fri Apr 03 14:58:12 2015 +0100
+++ b/tests/uniname/test-uninames.c	Tue Apr 07 11:09:23 2015 +0900
@@ -181,6 +181,16 @@
     }
 }
 
+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 @@
 
                 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 @@
   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;
 }