• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2018  Google, Inc.
3  *
4  *  This is part of HarfBuzz, a text shaping library.
5  *
6  * Permission is hereby granted, without written agreement and without
7  * license or royalty fees, to use, copy, modify, and distribute this
8  * software and its documentation for any purpose, provided that the
9  * above copyright notice and the following two paragraphs appear in
10  * all copies of this software.
11  *
12  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16  * DAMAGE.
17  *
18  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
21  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23  *
24  * Google Author(s): Garret Rieger
25  */
26 
27 #include "hb-test.h"
28 #include "hb-subset-test.h"
29 
30 /* Unit tests for hb-subset-glyf.h */
31 
32 static void
test_subset_32_tables(void)33 test_subset_32_tables (void)
34 {
35   hb_face_t *face = hb_test_open_font_file ("../fuzzing/fonts/oom-6ef8c96d3710262511bcc730dce9c00e722cb653");
36 
37   hb_subset_input_t *input = hb_subset_input_create_or_fail ();
38   hb_set_t *codepoints = hb_subset_input_unicode_set (input);
39   hb_face_t *subset;
40 
41   hb_set_add (codepoints, 'a');
42   hb_set_add (codepoints, 'b');
43   hb_set_add (codepoints, 'c');
44 
45   subset = hb_subset (face, input);
46   g_assert (subset);
47   g_assert (subset != hb_face_get_empty ());
48 
49   hb_subset_input_destroy (input);
50   hb_face_destroy (subset);
51   hb_face_destroy (face);
52 }
53 
54 static void
test_subset_no_inf_loop(void)55 test_subset_no_inf_loop (void)
56 {
57   hb_face_t *face = hb_test_open_font_file ("../fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5521982557782016");
58 
59   hb_subset_input_t *input = hb_subset_input_create_or_fail ();
60   hb_set_t *codepoints = hb_subset_input_unicode_set (input);
61   hb_face_t *subset;
62 
63   hb_set_add (codepoints, 'a');
64   hb_set_add (codepoints, 'b');
65   hb_set_add (codepoints, 'c');
66 
67   subset = hb_subset (face, input);
68   g_assert (subset);
69   g_assert (subset == hb_face_get_empty ());
70 
71   hb_subset_input_destroy (input);
72   hb_face_destroy (subset);
73   hb_face_destroy (face);
74 }
75 
76 static void
test_subset_crash(void)77 test_subset_crash (void)
78 {
79   hb_face_t *face = hb_test_open_font_file ("../fuzzing/fonts/crash-4b60576767ee4d9fe1cc10959d89baf73d4e8249");
80 
81   hb_subset_input_t *input = hb_subset_input_create_or_fail ();
82   hb_set_t *codepoints = hb_subset_input_unicode_set (input);
83   hb_face_t *subset;
84 
85   hb_set_add (codepoints, 'a');
86   hb_set_add (codepoints, 'b');
87   hb_set_add (codepoints, 'c');
88 
89   subset = hb_subset (face, input);
90   g_assert (subset);
91   g_assert (subset == hb_face_get_empty ());
92 
93   hb_subset_input_destroy (input);
94   hb_face_destroy (subset);
95   hb_face_destroy (face);
96 }
97 
98 int
main(int argc,char ** argv)99 main (int argc, char **argv)
100 {
101   hb_test_init (&argc, &argv);
102 
103   hb_test_add (test_subset_32_tables);
104   hb_test_add (test_subset_no_inf_loop);
105   hb_test_add (test_subset_crash);
106 
107   return hb_test_run();
108 }
109