summaryrefslogtreecommitdiff
path: root/tests/testcontext.c
blob: 9c9dcaef8c78cc5a75afddeaee135cd89b1946d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* Pango
 * testcontext.c: Test program for PangoContext
 *
 * Copyright (C) 2021 Matthias Clasen
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <glib.h>
#include <pango/pango.h>

static void
test_set_language (void)
{
  PangoContext *context;

  context = pango_context_new ();

  pango_context_set_language (context, pango_language_from_string ("de-de"));
  g_assert_true (pango_context_get_language (context) == pango_language_from_string ("de-de"));

  pango_context_set_language (context, NULL);
  g_assert_null (pango_context_get_language (context));

  g_object_unref (context);
}

static void
test_set_base_dir (void)
{
  PangoContext *context;

  context = pango_context_new ();

  pango_context_set_base_dir (context, PANGO_DIRECTION_RTL);
  g_assert_true (pango_context_get_base_dir (context) == PANGO_DIRECTION_RTL);

  pango_context_set_base_dir (context, PANGO_DIRECTION_WEAK_LTR);
  g_assert_true (pango_context_get_base_dir (context) == PANGO_DIRECTION_WEAK_LTR);

  g_object_unref (context);
}

static void
test_set_base_gravity (void)
{
  PangoContext *context;

  context = pango_context_new ();

  pango_context_set_base_gravity (context, PANGO_GRAVITY_SOUTH);
  g_assert_true (pango_context_get_base_gravity (context) == PANGO_GRAVITY_SOUTH);
  g_assert_true (pango_context_get_gravity (context) == PANGO_GRAVITY_SOUTH);

  pango_context_set_base_gravity (context, PANGO_GRAVITY_AUTO);
  g_assert_true (pango_context_get_base_gravity (context) == PANGO_GRAVITY_AUTO);
  g_assert_true (pango_context_get_gravity (context) == PANGO_GRAVITY_SOUTH);

  g_object_unref (context);
}

static void
test_set_gravity_hint (void)
{
  PangoContext *context;

  context = pango_context_new ();

  pango_context_set_gravity_hint (context, PANGO_GRAVITY_HINT_NATURAL);
  g_assert_true (pango_context_get_gravity_hint (context) == PANGO_GRAVITY_HINT_NATURAL);

  pango_context_set_gravity_hint (context, PANGO_GRAVITY_HINT_STRONG);
  g_assert_true (pango_context_get_gravity_hint (context) == PANGO_GRAVITY_HINT_STRONG);

  g_object_unref (context);
}

static void
test_set_round_glyph_positions (void)
{
  PangoContext *context;

  context = pango_context_new ();

  pango_context_set_round_glyph_positions (context, TRUE);
  g_assert_true (pango_context_get_round_glyph_positions (context));

  pango_context_set_round_glyph_positions (context, FALSE);
  g_assert_false (pango_context_get_round_glyph_positions (context));

  g_object_unref (context);
}

int
main (int argc, char *argv[])
{
  g_test_init (&argc, &argv, NULL);

  g_test_add_func ("/context/set-language", test_set_language);
  g_test_add_func ("/context/set-base-dir", test_set_base_dir);
  g_test_add_func ("/context/set-base-gravity", test_set_base_gravity);
  g_test_add_func ("/context/set-gravity-hint", test_set_gravity_hint);
  g_test_add_func ("/context/set-round-glyph-positions", test_set_round_glyph_positions);

  return g_test_run ();
}