Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/harfbuzz/src/test-algs.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 © 2019 Facebook, 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 * Facebook Author(s): Behdad Esfahbod | |
| 25 */ | |
| 26 | |
| 27 #include "hb.hh" | |
| 28 #include "hb-algs.hh" | |
| 29 #include "hb-set.hh" | |
| 30 | |
| 31 | |
| 32 static char * | |
| 33 test_func (int a, char **b) | |
| 34 { | |
| 35 return b ? b[a] : nullptr; | |
| 36 } | |
| 37 | |
| 38 struct A | |
| 39 { | |
| 40 void a () {} | |
| 41 }; | |
| 42 | |
| 43 int | |
| 44 main (int argc, char **argv) | |
| 45 { | |
| 46 int i = 1; | |
| 47 auto p = hb_pair (1, i); | |
| 48 | |
| 49 p.second = 2; | |
| 50 assert (i == 2); | |
| 51 | |
| 52 const int c = 3; | |
| 53 auto pc = hb_pair (1, c); | |
| 54 assert (pc.second == 3); | |
| 55 | |
| 56 auto q = p; | |
| 57 assert (&q != &p); | |
| 58 q.second = 4; | |
| 59 assert (i == 4); | |
| 60 | |
| 61 hb_invoke (test_func, 0, nullptr); | |
| 62 | |
| 63 A a; | |
| 64 hb_invoke (&A::a, a); | |
| 65 | |
| 66 assert (1 == hb_min (8, 1)); | |
| 67 assert (8 == hb_max (8, 1)); | |
| 68 | |
| 69 int x = 1, y = 2; | |
| 70 hb_min (x, 3); | |
| 71 hb_min (3, x); | |
| 72 hb_min (x, 4 + 3); | |
| 73 int &z = hb_min (x, y); | |
| 74 z = 3; | |
| 75 assert (x == 3); | |
| 76 | |
| 77 hb_pair_t<const int*, int> xp = hb_pair_t<int *, long> (nullptr, 0); | |
| 78 xp = hb_pair_t<int *, double> (nullptr, 1); | |
| 79 xp = hb_pair_t<const int*, int> (nullptr, 1); | |
| 80 | |
| 81 assert (3 == hb_partial (hb_min, 3) (4)); | |
| 82 assert (3 == hb_partial<1> (hb_min, 4) (3)); | |
| 83 | |
| 84 auto M0 = hb_partial<2> (hb_max, 0); | |
| 85 assert (M0 (-2) == 0); | |
| 86 assert (M0 (+2) == 2); | |
| 87 | |
| 88 assert (hb_add (2) (5) == 7); | |
| 89 assert (hb_add (5) (2) == 7); | |
| 90 | |
| 91 x = 1; | |
| 92 assert (++hb_inc (x) == 3); | |
| 93 assert (x == 3); | |
| 94 | |
| 95 hb_set_t set1 {1}; | |
| 96 hb_set_t set2 {2}; | |
| 97 | |
| 98 assert (hb_hash (set1) != hb_hash (set2)); | |
| 99 assert (hb_hash (set1) == hb_hash (hb_set_t {1})); | |
| 100 assert (hb_hash (set1) != hb_hash (hb_set_t {})); | |
| 101 assert (hb_hash (set1) != hb_hash (hb_set_t {2})); | |
| 102 assert (hb_hash (set2) == hb_hash (hb_set_t {2})); | |
| 103 | |
| 104 /* hb_hash, unlike std::hash, dereferences pointers. */ | |
| 105 assert (hb_hash (set1) == hb_hash (&set1)); | |
| 106 assert (hb_hash (set1) == hb_hash (hb::shared_ptr<hb_set_t> {hb_set_reference (&set1)})); | |
| 107 assert (hb_hash (set1) == hb_hash (hb::unique_ptr<hb_set_t> {hb_set_reference (&set1)})); | |
| 108 | |
| 109 return 0; | |
| 110 } |
