[liblouis-liblouisxml] [liblouis] r664 committed - Simplify the code

  • From: liblouis@xxxxxxxxxxxxxx
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Fri, 01 Jun 2012 21:06:59 +0000

Revision: 664
Author:   christian.egli@xxxxxxxxxxxxxx
Date:     Fri Jun  1 14:06:45 2012
Log:      Simplify the code

http://code.google.com/p/liblouis/source/detail?r=664

Modified:
 /trunk/tests/squash_space.c

=======================================
--- /trunk/tests/squash_space.c Fri Jun  1 07:52:18 2012
+++ /trunk/tests/squash_space.c Fri Jun  1 14:06:45 2012
@@ -7,7 +7,7 @@
 {

   int result = 0;
-  const char *tests_using_repeated[] = {
+  const char *tests[] = {
     /* first column is the text, the second is the expected value */
     " ", " ",
     /* the usual case */
@@ -46,23 +46,25 @@
     "\n    ",     "\n "
   };

-  int tests_len = sizeof(tests_using_repeated)/sizeof(char*);
+  int tests_len = sizeof(tests)/sizeof(char*);

   for (int i = 0; i < tests_len; i += 2)
- result |= check_translation("squash_space_with_repeated.utb", tests_using_repeated[i], NULL, tests_using_repeated[i+1]);
-
-  const char *tests[] = {
-    /* first column is the text, the second is the expected value */
-    " ", " ",
-    /* the usual case */
-    "                                                                                ", 
" ",
+ result |= check_translation("squash_space_with_repeated.utb", tests[i], NULL, tests[i+1]);
+
+  /* A number of strings that we want to squash, i.e. they should all
+     result in an output of one space */
+  const char *strings[] = {
+    /* a simple space */
+    " ",
+    /* a long string */
+    "                                                                               
 ",
     /* a very long string */
" " \ " " \ " " \ " " \ " " \
-    "                                                                                ", 
" ",
+    "                                                                               
 ",
     /* an even longer string */
" " \ " " \
@@ -79,29 +81,30 @@
" " \ " " \ " " \
-    "                                                                                ", 
" ",
-    /* a string containing tabs */
-    "    \t",     " ",
-    "    \t    ", " ",
-    "\t    ",     " ",
+    "                                                                               
 ",
+    /* a couple of strings containing tabs */
+    "    \t",
+    "    \t    ",
+    "\t    ",
     /* Strings containing newlines */
-    "    \n",     " ",
-    "    \n    ", " ",
-    "\n    ",     " ",
+    "    \n",
+    "    \n    ",
+    "\n    ",
     /* All mixed */
-    "    \n    \t    \n    \t\t    \n\n\n\t\t    ",     " ",
+    "    \n    \t    \n    \t\t    \n\n\n\t\t    ",
   };
-
-  tests_len = sizeof(tests)/sizeof(char*);
-
-  for (int i = 0; i < tests_len; i += 2)
- result |= check_translation("squash_space_with_correct.utb", tests[i], NULL, tests[i+1]);
-
-  for (int i = 0; i < tests_len; i += 2)
- result |= check_translation("squash_space_with_context_1.utb", tests[i], NULL, tests[i+1]);
-
-  for (int i = 0; i < tests_len; i += 2)
- result |= check_translation("squash_space_with_context_2.utb", tests[i], NULL, tests[i+1]);
+  const char *expected = " ";
+
+  tests_len = sizeof(strings)/sizeof(char*);
+
+  for (int i = 0; i < tests_len; i++)
+ result |= check_translation("squash_space_with_correct.utb", strings[i], NULL, expected);
+
+  for (int i = 0; i < tests_len; i++)
+ result |= check_translation("squash_space_with_context_1.utb", strings[i], NULL, expected);
+
+  for (int i = 0; i < tests_len; i++)
+ result |= check_translation("squash_space_with_context_2.utb", strings[i], NULL, expected);


   return result;
For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

Other related posts:

  • » [liblouis-liblouisxml] [liblouis] r664 committed - Simplify the code - liblouis