Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/harfbuzz/src/graph/test-classdef-graph.cc @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /* | |
| 2 * Copyright © 2022 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 "gsubgpos-context.hh" | |
| 28 #include "classdef-graph.hh" | |
| 29 | |
| 30 typedef hb_pair_t<hb_codepoint_t, hb_codepoint_t> gid_and_class_t; | |
| 31 typedef hb_vector_t<gid_and_class_t> gid_and_class_list_t; | |
| 32 | |
| 33 | |
| 34 static bool incremental_size_is (const gid_and_class_list_t& list, unsigned klass, | |
| 35 unsigned cov_expected, unsigned class_def_expected) | |
| 36 { | |
| 37 graph::class_def_size_estimator_t estimator (list.iter ()); | |
| 38 | |
| 39 unsigned result = estimator.incremental_coverage_size (klass); | |
| 40 if (result != cov_expected) | |
| 41 { | |
| 42 printf ("FAIL: coverage expected size %u but was %u\n", cov_expected, result); | |
| 43 return false; | |
| 44 } | |
| 45 | |
| 46 result = estimator.incremental_class_def_size (klass); | |
| 47 if (result != class_def_expected) | |
| 48 { | |
| 49 printf ("FAIL: class def expected size %u but was %u\n", class_def_expected, result); | |
| 50 return false; | |
| 51 } | |
| 52 | |
| 53 return true; | |
| 54 } | |
| 55 | |
| 56 static void test_class_and_coverage_size_estimates () | |
| 57 { | |
| 58 gid_and_class_list_t empty = { | |
| 59 }; | |
| 60 assert (incremental_size_is (empty, 0, 0, 0)); | |
| 61 assert (incremental_size_is (empty, 1, 0, 0)); | |
| 62 | |
| 63 gid_and_class_list_t class_zero = { | |
| 64 {5, 0}, | |
| 65 }; | |
| 66 assert (incremental_size_is (class_zero, 0, 2, 0)); | |
| 67 | |
| 68 gid_and_class_list_t consecutive = { | |
| 69 {4, 0}, | |
| 70 {5, 0}, | |
| 71 {6, 1}, | |
| 72 {7, 1}, | |
| 73 {8, 2}, | |
| 74 {9, 2}, | |
| 75 {10, 2}, | |
| 76 {11, 2}, | |
| 77 }; | |
| 78 assert (incremental_size_is (consecutive, 0, 4, 0)); | |
| 79 assert (incremental_size_is (consecutive, 1, 4, 4)); | |
| 80 assert (incremental_size_is (consecutive, 2, 8, 6)); | |
| 81 | |
| 82 gid_and_class_list_t non_consecutive = { | |
| 83 {4, 0}, | |
| 84 {5, 0}, | |
| 85 | |
| 86 {6, 1}, | |
| 87 {7, 1}, | |
| 88 | |
| 89 {9, 2}, | |
| 90 {10, 2}, | |
| 91 {11, 2}, | |
| 92 {12, 2}, | |
| 93 }; | |
| 94 assert (incremental_size_is (non_consecutive, 0, 4, 0)); | |
| 95 assert (incremental_size_is (non_consecutive, 1, 4, 6)); | |
| 96 assert (incremental_size_is (non_consecutive, 2, 8, 6)); | |
| 97 | |
| 98 gid_and_class_list_t multiple_ranges = { | |
| 99 {4, 0}, | |
| 100 {5, 0}, | |
| 101 | |
| 102 {6, 1}, | |
| 103 {7, 1}, | |
| 104 | |
| 105 {9, 1}, | |
| 106 | |
| 107 {11, 1}, | |
| 108 {12, 1}, | |
| 109 {13, 1}, | |
| 110 }; | |
| 111 assert (incremental_size_is (multiple_ranges, 0, 4, 0)); | |
| 112 assert (incremental_size_is (multiple_ranges, 1, 2 * 6, 3 * 6)); | |
| 113 } | |
| 114 | |
| 115 int | |
| 116 main (int argc, char **argv) | |
| 117 { | |
| 118 test_class_and_coverage_size_estimates (); | |
| 119 } |
