summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/dump-boundaries.c24
-rw-r--r--tests/testboundaries.c46
-rw-r--r--tests/testcolor.c8
-rw-r--r--tests/testiter.c44
-rw-r--r--tests/testscript.c24
5 files changed, 73 insertions, 73 deletions
diff --git a/tests/dump-boundaries.c b/tests/dump-boundaries.c
index ba4c343b..9d6aefa7 100644
--- a/tests/dump-boundaries.c
+++ b/tests/dump-boundaries.c
@@ -32,7 +32,7 @@ static void fail (const char *format, ...) G_GNUC_PRINTF (1, 2) G_GNUC_NORETURN;
static void fail (const char *format, ...)
{
char *str;
-
+
va_list args;
va_start (args, format);
@@ -40,7 +40,7 @@ static void fail (const char *format, ...)
va_end (args);
fprintf (stderr, "Error: %s\n", str);
-
+
g_free (str);
exit (1);
@@ -53,10 +53,10 @@ dump_text (const char *text)
PangoLogAttr *attrs;
int i;
gunichar *ucs4;
-
+
if (!g_utf8_validate (text, -1, NULL))
fail ("Invalid UTF-8 in file");
-
+
len = g_utf8_strlen (text, -1);
attrs = g_new0 (PangoLogAttr, len + 1);
@@ -68,22 +68,22 @@ dump_text (const char *text)
len + 1);
ucs4 = g_utf8_to_ucs4 (text, -1, NULL, NULL, NULL);
-
+
i = 0;
while (i <= len)
{
char buf[7] = { '\0', };
char *loc;
-
+
g_unichar_to_utf8 (ucs4[i], buf);
if (*buf == '\n')
loc = g_strdup ("\\n");
else if (*buf == '\r')
loc = g_strdup ("\\r");
- else
+ else
loc = g_locale_from_utf8 (buf, -1, NULL, NULL, NULL);
-
+
g_print (CHFORMAT " (%s):\t line_break = %d mandatory_break = %d char_break = %d\n"
" \t\t white = %d cursor_position = %d\n"
" \t\t word_start = %d word_end = %d\n"
@@ -101,7 +101,7 @@ dump_text (const char *text)
attrs[i].is_sentence_end);
g_free (loc);
-
+
++i;
}
@@ -119,14 +119,14 @@ main (int argc,
if (argc < 2)
fail ("must give a filename on the command line");
-
+
if (!g_file_get_contents (argv[1], &text, NULL, NULL))
fail ("Couldn't open sample text file");
-
+
dump_text (text);
g_free (text);
-
+
return 0;
}
diff --git a/tests/testboundaries.c b/tests/testboundaries.c
index edc5b184..45177b09 100644
--- a/tests/testboundaries.c
+++ b/tests/testboundaries.c
@@ -71,7 +71,7 @@ static void fail (const char *format, ...)
{
char *str;
char *line_text;
-
+
va_list args;
va_start (args, format);
@@ -79,7 +79,7 @@ static void fail (const char *format, ...)
va_end (args);
line_text = g_strndup (line_start, line_end - line_start);
-
+
fprintf (stderr, "line %d offset %d char is " CHFORMAT ": %s\n (line is '%s')\n", line, offset, current_wc, str, line_text);
g_free (str);
g_free (line_text);
@@ -112,13 +112,13 @@ log_attr_foreach (const char *text,
gunichar next_wc;
GUnicodeType prev_type;
GUnicodeType next_type;
-
+
if (next == end)
return;
offset = 0;
line = 0;
-
+
prev_type = (GUnicodeType) -1;
prev_wc = 0;
@@ -127,7 +127,7 @@ log_attr_foreach (const char *text,
line_start = text;
line_end = text;
-
+
while (next_wc != 0)
{
GUnicodeType type;
@@ -137,10 +137,10 @@ log_attr_foreach (const char *text,
type = next_type;
current_wc = wc;
-
+
next = g_utf8_next_char (next);
line_end = next;
-
+
if (next >= end)
next_wc = 0;
else
@@ -155,7 +155,7 @@ log_attr_foreach (const char *text,
i != 0 ? &attrs[i-1] : NULL,
next_wc != 0 ? &attrs[i+1] : NULL,
data);
-
+
prev_type = type;
prev_wc = wc;
++i;
@@ -190,7 +190,7 @@ check_line_char (gunichar wc,
prev_break_type = g_unichar_break_type (prev_wc);
else
prev_break_type = G_UNICODE_BREAK_UNKNOWN;
-
+
if (wc == '\n')
{
if (prev_wc == '\r')
@@ -198,11 +198,11 @@ check_line_char (gunichar wc,
if (attr->is_line_break)
fail ("line break between \\r and \\n");
}
-
+
if (next_attr && !next_attr->is_line_break)
fail ("no line break after \\n");
}
-
+
if (attr->is_line_break && prev_wc == 0)
fail ("first char in string should not be marked as a line break");
@@ -217,13 +217,13 @@ check_line_char (gunichar wc,
if (attr->is_mandatory_break && !attr->is_line_break)
fail ("mandatory breaks must also be marked as regular breaks");
-
-
+
+
/* FIXME use the break tables from break.c to automatically
* check invariants for each cell in the table. Shouldn't
* be that hard to do.
*/
-
+
if (break_type == G_UNICODE_BREAK_OPEN_PUNCTUATION &&
prev_break_type == G_UNICODE_BREAK_OPEN_PUNCTUATION &&
attr->is_line_break &&
@@ -240,7 +240,7 @@ check_line_char (gunichar wc,
prev_break_type == G_UNICODE_BREAK_ALPHABETIC &&
attr->is_line_break &&
!attr->is_mandatory_break)
- fail ("can't break letter-quotemark sequence");
+ fail ("can't break letter-quotemark sequence");
}
static void
@@ -296,7 +296,7 @@ print_sentences (const char *text,
g_free (s);
last = p;
}
-
+
p = g_utf8_next_char (p);
++i;
}
@@ -310,7 +310,7 @@ check_invariants (const char *text)
if (!g_utf8_validate (text, -1, NULL))
fail ("Invalid UTF-8 in test text");
-
+
len = g_utf8_strlen (text, -1);
attrs = g_new0 (PangoLogAttr, len + 1);
@@ -320,7 +320,7 @@ check_invariants (const char *text)
pango_language_from_string ("C"),
attrs,
len + 1);
-
+
check_line_invariants (text, attrs);
check_sentence_invariants (text, attrs);
check_grapheme_invariants (text, attrs);
@@ -329,12 +329,12 @@ check_invariants (const char *text)
#if 0
print_sentences (text, attrs);
#endif
-
+
g_free (attrs);
}
int
-main (int argc, char *argv[])
+main (int argc, char *argv[])
{
gchar *text;
const gchar *srcdir;
@@ -347,16 +347,16 @@ main (int argc, char *argv[])
srcdir = ".";
filename = g_strdup_printf ("%s/boundaries.utf8", srcdir);
-
+
if (!g_file_get_contents (filename, &text, NULL, NULL))
fail ("Couldn't open sample text file");
-
+
check_invariants (text);
g_free (text);
printf ("testboundaries passed\n");
-
+
return 0;
}
diff --git a/tests/testcolor.c b/tests/testcolor.c
index 1befafb9..1995d3d6 100644
--- a/tests/testcolor.c
+++ b/tests/testcolor.c
@@ -26,7 +26,7 @@ typedef struct _ColorSpec {
const gchar *spec;
gboolean valid;
guint16 red;
- guint16 green;
+ guint16 green;
guint16 blue;
} ColorSpec;
@@ -38,7 +38,7 @@ static gboolean test_color (ColorSpec *spec)
accepted = pango_color_parse (&color, spec->spec);
if (accepted == spec->valid &&
- (!accepted ||
+ (!accepted ||
(color.red == spec->red &&
color.green == spec->green &&
color.blue == spec->blue)))
@@ -78,8 +78,8 @@ ColorSpec specs [] = {
{ NULL, 0, 0, 0, 0 }
};
-int
-main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
gboolean success;
ColorSpec *spec;
diff --git a/tests/testiter.c b/tests/testiter.c
index 76bb7f1b..65986d52 100644
--- a/tests/testiter.c
+++ b/tests/testiter.c
@@ -38,13 +38,13 @@ static void verbose (const char *format, ...) G_GNUC_PRINTF (1, 2);
static void
verbose (const char *format, ...)
{
-#ifdef VERBOSE
+#ifdef VERBOSE
va_list vap;
-
+
va_start (vap, format);
vfprintf (stderr, format, vap);
va_end (vap);
-#endif
+#endif
}
#define LAYOUT_WIDTH (80 * PANGO_SCALE)
@@ -87,7 +87,7 @@ iter_char_test (PangoLayout *layout)
text = pango_layout_get_text (layout);
num_chars = g_utf8_strlen (text, -1);
-
+
iter = pango_layout_get_iter (layout);
iter_next_ok = TRUE;
@@ -99,15 +99,15 @@ iter_char_test (PangoLayout *layout)
index = pango_layout_iter_get_index (iter);
ptr = text + index;
char_str = g_strndup (ptr, g_utf8_next_char (ptr) - ptr);
- verbose ("i=%d (visual), index = %d '%s':\n",
+ verbose ("i=%d (visual), index = %d '%s':\n",
i, index, char_str);
g_free (char_str);
pango_layout_iter_get_char_extents (iter, &extents);
verbose (" char extents: x=%d,y=%d w=%d,h=%d\n",
- extents.x, extents.y,
+ extents.x, extents.y,
extents.width, extents.height);
-
+
run = pango_layout_iter_get_run (iter);
if (run)
@@ -116,23 +116,23 @@ iter_char_test (PangoLayout *layout)
pango_layout_iter_get_run_extents(iter, NULL, &run_extents);
offset = run->item->offset;
rtl = run->item->analysis.level%2;
- verbose (" (current run: offset=%d,x=%d,len=%d,rtl=%d)\n",
+ verbose (" (current run: offset=%d,x=%d,len=%d,rtl=%d)\n",
offset, run_extents.x, run->item->length, rtl);
-
+
/* Calculate expected x result using index_to_x */
- pango_glyph_string_index_to_x (run->glyphs,
+ pango_glyph_string_index_to_x (run->glyphs,
(char *)(text + offset), run->item->length,
&run->item->analysis,
index - offset, FALSE, &leading_x);
- pango_glyph_string_index_to_x (run->glyphs,
+ pango_glyph_string_index_to_x (run->glyphs,
(char *)(text + offset), run->item->length,
&run->item->analysis,
index - offset, TRUE, &trailing_x);
-
+
x0 = run_extents.x + MIN (leading_x, trailing_x);
x1 = run_extents.x + MAX (leading_x, trailing_x);
-
- verbose (" (index_to_x ind=%d: expected x=%d, width=%d)\n",
+
+ verbose (" (index_to_x ind=%d: expected x=%d, width=%d)\n",
index - offset, x0, x1 - x0);
g_assert (extents.x == x0);
@@ -142,7 +142,7 @@ iter_char_test (PangoLayout *layout)
{
/* We're on a line terminator */
}
-
+
iter_next_ok = pango_layout_iter_next_char (iter);
verbose ("more to go? %d\n", iter_next_ok);
}
@@ -182,29 +182,29 @@ iter_cluster_test (PangoLayout *layout)
g_assert (pango_layout_iter_get_run (iter));
index = pango_layout_iter_get_index (iter);
-
+
pango_layout_iter_get_cluster_extents (iter, NULL, &extents);
-
+
iter_next_ok = pango_layout_iter_next_cluster (iter);
-
+
verbose ("index = %d:\n", index);
verbose (" cluster extents: x=%d,y=%d w=%d,h=%d\n",
- extents.x, extents.y,
+ extents.x, extents.y,
extents.width, extents.height);
verbose ("more to go? %d\n", iter_next_ok);
/* All the clusters on a line should be next to each other and occupy
* the entire line. They advance linearly from left to right */
g_assert (extents.width >= 0);
-
+
if (last_line == line)
g_assert (extents.x == expected_next_x);
- expected_next_x = extents.x + extents.width;
+ expected_next_x = extents.x + extents.width;
last_line = line;
}
-
+
g_assert (!iter_next_ok);
pango_layout_iter_free (iter);
diff --git a/tests/testscript.c b/tests/testscript.c
index ebe6891d..d2ecaa8b 100644
--- a/tests/testscript.c
+++ b/tests/testscript.c
@@ -38,7 +38,7 @@
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
@@ -48,7 +48,7 @@
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
+ *
* Except as contained in this notice, the name of a copyright holder
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
@@ -90,14 +90,14 @@ unescape (const char *text)
for (p = text; *p; p = g_utf8_next_char (p))
{
gunichar ch = g_utf8_get_char (p);
-
+
if (escaped)
{
if (ch == 'u' || ch == 'U')
{
int n_chars = ch == 'u' ? 4 : 8;
int i;
-
+
ch = 0;
for (i = 0; i < n_chars; i++)
{
@@ -190,7 +190,7 @@ test_script_iter (void)
const char *end;
PangoScript script;
unsigned int i;
-
+
for (i = 0; i < G_N_ELEMENTS(test_data); i++)
{
test_data[i].run_text = unescape (test_data[i].run_text_escaped);
@@ -201,18 +201,18 @@ test_script_iter (void)
#ifdef VERBOSE
g_print ("Total length: %d\n", all->len);
-#endif
+#endif
pos = all->str;
for (i = 0; i < G_N_ELEMENTS(test_data); i++)
{
char *next_pos = pos + strlen (test_data[i].run_text);
gboolean result;
-
+
pango_script_iter_get_range (iter, &start, &end, &script);
#ifdef VERBOSE
g_print ("Range: %d-%d: %d\n", start - all->str, end - all->str, script);
-#endif
+#endif
ASSERT (start == pos);
ASSERT (end == next_pos);
@@ -230,18 +230,18 @@ test_script_iter (void)
* Test an empty string.
*/
iter = pango_script_iter_new (all->str, 0);
-
+
pango_script_iter_get_range (iter, &start, &end, &script);
-
+
ASSERT (start == all->str);
ASSERT (end == all->str);
ASSERT (script == PANGO_SCRIPT_COMMON);
ASSERT (!pango_script_iter_next (iter));
-
+
pango_script_iter_free (iter);
/* Cleanup */
-
+
for (i = 0; i < G_N_ELEMENTS (test_data); i++)
g_free (test_data[i].run_text);