* MoonlightTypeConverter.cs: Convert CacheMode's from strings.
[moon.git] / cairo / test / font-options.c
blobfd61a73e645faec2ef51b706e199ebbb09b548f5
1 /*
2 * Copyright © 2008 Chris Wilson
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Chris Wilson not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior
11 * permission. Chris Wilson makes no representations about the
12 * suitability of this software for any purpose. It is provided "as
13 * is" without express or implied warranty.
15 * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
16 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 * FITNESS, IN NO EVENT SHALL CHRIS WILSON BE LIABLE FOR ANY SPECIAL,
18 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
19 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
21 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: Chris Wilson <chris@chris-wilson.co.uk>
26 #include "cairo-test.h"
28 #include <cairo.h>
29 #include <assert.h>
31 int
32 main (void)
34 cairo_test_context_t ctx;
35 cairo_font_options_t *default_options;
36 cairo_font_options_t *nil_options;
37 cairo_surface_t *surface;
38 cairo_matrix_t identity;
39 cairo_t *cr;
40 cairo_scaled_font_t *scaled_font;
42 cairo_test_init (&ctx, "font-options");
44 /* first check NULL handling of cairo_font_options_t */
45 default_options = cairo_font_options_create ();
46 assert (cairo_font_options_status (default_options) == CAIRO_STATUS_SUCCESS);
47 nil_options = cairo_font_options_copy (NULL);
48 assert (cairo_font_options_status (nil_options) == CAIRO_STATUS_NO_MEMORY);
50 assert (cairo_font_options_equal (default_options, default_options));
51 assert (! cairo_font_options_equal (default_options, nil_options));
52 assert (! cairo_font_options_equal (NULL, nil_options));
53 assert (! cairo_font_options_equal (nil_options, nil_options));
54 assert (! cairo_font_options_equal (default_options, NULL));
55 assert (! cairo_font_options_equal (NULL, default_options));
57 assert (cairo_font_options_hash (default_options) == cairo_font_options_hash (nil_options));
58 assert (cairo_font_options_hash (NULL) == cairo_font_options_hash (nil_options));
59 assert (cairo_font_options_hash (default_options) == cairo_font_options_hash (NULL));
61 cairo_font_options_merge (NULL, NULL);
62 cairo_font_options_merge (default_options, NULL);
63 cairo_font_options_merge (default_options, nil_options);
65 cairo_font_options_set_antialias (NULL, CAIRO_ANTIALIAS_DEFAULT);
66 cairo_font_options_get_antialias (NULL);
67 assert (cairo_font_options_get_antialias (default_options) == CAIRO_ANTIALIAS_DEFAULT);
69 cairo_font_options_set_subpixel_order (NULL, CAIRO_SUBPIXEL_ORDER_DEFAULT);
70 cairo_font_options_get_subpixel_order (NULL);
71 assert (cairo_font_options_get_subpixel_order (default_options) == CAIRO_SUBPIXEL_ORDER_DEFAULT);
73 cairo_font_options_set_hint_style (NULL, CAIRO_HINT_STYLE_DEFAULT);
74 cairo_font_options_get_hint_style (NULL);
75 assert (cairo_font_options_get_hint_style (default_options) == CAIRO_HINT_STYLE_DEFAULT);
77 cairo_font_options_set_hint_metrics (NULL, CAIRO_HINT_METRICS_DEFAULT);
78 cairo_font_options_get_hint_metrics (NULL);
79 assert (cairo_font_options_get_hint_metrics (default_options) == CAIRO_HINT_METRICS_DEFAULT);
81 cairo_font_options_destroy (NULL);
82 cairo_font_options_destroy (default_options);
83 cairo_font_options_destroy (nil_options);
86 /* Now try creating fonts with NULLs */
87 surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 0, 0);
88 cr = cairo_create (surface);
89 cairo_surface_destroy (surface);
91 cairo_matrix_init_identity (&identity);
92 scaled_font = cairo_scaled_font_create (cairo_get_font_face (cr),
93 &identity, &identity,
94 NULL);
95 assert (cairo_scaled_font_status (scaled_font) == CAIRO_STATUS_NULL_POINTER);
96 cairo_scaled_font_get_font_options (scaled_font, NULL);
97 cairo_scaled_font_destroy (scaled_font);
99 assert (cairo_status (cr) == CAIRO_STATUS_SUCCESS);
100 cairo_get_font_options (cr, NULL);
101 cairo_set_font_options (cr, NULL);
102 assert (cairo_status (cr) == CAIRO_STATUS_NULL_POINTER);
104 cairo_destroy (cr);
106 cairo_test_fini (&ctx);
108 return CAIRO_TEST_SUCCESS;