Commit Graph
47 Commits
Author SHA1 Message Date
Behdad Esfahbod bf0828e9f4 [set] Restore sorted-array additions to inverted sets (#6333)
Adding a sorted array to an inverted set delegates to the underlying deletion path, but set_sorted_array() always added bits. Excluded members stayed excluded, and existing included members could become excluded.

Use the requested bit value, as set_array() already does. The regression covers duplicates, excluded and included members, and both existing and absent pages.

Assisted-by: OpenAI Codex
2026-10-07 12:19:48 -06:00
Behdad Esfahbod 0529c75459 [vector] Preserve contents on self-copy assignment (#6331)
Copy assignment resets the destination before reading the source. When
they are the same vector, this also clears the source. In particular,
hb_set_set(set, set) loses the set's stored pages.

Return immediately for self assignment. Cover trivial and nontrivial
vector elements and public set assignment in both inversion modes.

Validation: both regressions fail before the fix; meson test -C build
passes (261 passed, 1 skipped).

Assisted-by: OpenAI Codex
2026-10-07 12:16:05 -06:00
Behdad Esfahbod 3957e16e6c [set] Skip empty pages during reverse iteration (#6332)
Deleting the last member of a page leaves an empty page in the sparse set. `hb_bit_page_t::get_max()` returned zero for that page, so reverse iteration could report a value that was never in the set. For example, add and delete 512, then iterate backward from 1024: HarfBuzz reported 512 from an empty set.

Return INVALID for an empty page, matching get_min(), so previous() skips it. Cover reverse scalar/range iteration with retained empty pages, including inverted sets.

Assisted-by: OpenAI Codex
2026-10-07 12:09:14 -06:00
Behdad Esfahbod c22ae24405 [set] Reject unequal populations when comparing mixed inversion (#6329)
The mixed-inversion equality path compares zipped iterators, which stop
at the shorter set. An empty set therefore compares equal to a full
inverted set, as does any matching finite prefix.

Check populations before comparing members and add regression coverage
for empty sets and matching prefixes in both argument orders.

Validation: meson test -C build (261 passed, 1 skipped).

Assisted-by: OpenAI Codex
2026-10-07 12:06:58 -06:00
Behdad Esfahbod 4981dcc115 [set] Seek batch iteration correctly across missing pages (#6330)
When the cursor's page is absent, bfind selects the next stored page.
Using the cursor's offset in that different page can skip its members,
or skip the entire page when the cursor ends on a page boundary.

Apply the cursor offset only when the selected page matches its major
index. Cover batch and scalar iterator agreement across missing pages
for both ordinary and inverted sets.

Validation: the new regression fails before the fix; meson test -C build
passes (261 passed, 1 skipped).

Assisted-by: OpenAI Codex
2026-10-07 12:05:32 -06:00
Garret Rieger e67dee3f3a Add tests and benchmarks for hb_set_t next_range(). 2026-08-27 15:10:38 -06:00
Behdad Esfahbod 5e75e91ebf [set] Add hb_set_intersects API
Expose the exact set-intersection query so callers can test whether two
sets have any elements in common without copying and mutating a set.
The implementation handles inverted sets through the internal helper.

Document the new API with its release placeholder, add it to the docs
section index, and cover regular and inverted set combinations.

Tested with the full Meson test suite (270/270 passed).

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-19 16:00:05 -06:00
Garret Rieger 07e48ef1f0 Fix two bugs in hb_set_is_subset().
1. If smaller set has empty pages the subset checking logic was incorrectly incrementing the larger page index after skipping the empty smaller page index.
2. The logic for is_subset() on mixed inverted/not inverted sets was wrong.
2026-02-13 15:06:01 -07:00
Behdad Esfahbod 155e1e633b [test/api] Use g_assert_true instead of g_assert
The latter terminates the program. The former marks the test
as failing.
2025-04-06 03:49:15 -06:00
Behdad Esfahbod f69ecc9438 [test/api] Set protocol:tap 2025-04-06 02:34:48 -06:00
Behdad Esfahbod 25393288f0 [test] Fix compiler warning 2022-05-19 18:16:48 -06:00
Andrew John 0182988229 [set] Add call to export set contents to an array. (#3500)
[set] Add hb_set_next_many.
2022-03-25 09:36:44 -06:00
Andy John ef588ea97b Add option to insert a sorted arrays of values to sets. 2022-03-21 15:32:59 -06:00
Behdad Esfahbod 955f86a034 [test-set] Fix compiler warnings 2021-08-24 23:16:24 -06:00
Garret Rieger f84daccb4f [set] include null pool sets in the permutations tested by inverted_operations. 2021-08-24 16:51:11 -06:00
Garret Rieger 915550ab19 [set] remove inverted test TODO. 2021-08-19 17:48:38 -07:00
Garret Rieger c4ed582997 [set] add test for inverted set operations.
This test checks all possible set configurations against each operation type.
2021-08-19 17:47:41 -07:00
Garret Rieger 325fd6ddb8 [set] add tests for inverted set equality. 2021-08-19 15:54:31 -07:00
Garret Rieger 287032af6c [set] update set test TODO list. 2021-08-19 15:45:28 -07:00
Garret Rieger 5c003d80a6 [set] add tests for inverted previous iteration. 2021-08-19 15:41:12 -07:00
Garret Rieger 3f2cc582f2 [set] add basic and iteration set inverion tests. 2021-08-19 15:05:10 -07:00
Kurt Kartaltepe 2000f47ae5 [set] Compute is_subset by comparing pages.
Test subsets one page at a time instead of by codepoints. On my machine
this is about 250x faster than the previous implementation.
2021-05-26 14:15:25 -06:00
Garret Rieger 425ba1f4ab [subset] fixes infinite loop in hb_set_get_max().
Fixes https://oss-fuzz.com/testcase-detail/5363902507515904
2021-04-20 13:18:07 -06:00
ariza 4081439d2a tweak reflecting review & add test cases 2020-02-25 15:03:12 -08:00
ariza 173b745da8 fixed bug & added tests 2020-02-24 22:56:57 -08:00
ariza a5012e97c4 optimize hb_set_del_range()
fix issue #2193
2020-02-24 17:09:48 -08:00
Garret Rieger 2742c81624 Fix page_map corruption in hb_set_t during process().
If a process operation results in less pages then the current set has, it will likely corrupt the page_map since it overwrites page_map entries ahead of where it's processing. This fixes that problem by removing page_map entries that will be dropped. Then dropping orphaned pages and re-indexing retained pages.
2020-02-08 10:27:44 +03:30
Ebrahim Byagowi 34f357c78a Add test for hb_set_del 2018-10-19 20:23:36 +03:30
Behdad Esfahbod a353c1768d Remove test for deprecated hb_set_invert() 2018-10-09 01:05:28 -04:00
Ebrahim Byagowi 669ac81ac5 Fix test-set leak issue
See also https://github.com/harfbuzz/harfbuzz/pull/1169
2018-09-22 16:49:23 +03:30
Jonathan Kew a95cde15af [hb-set] Additional testcase for hb-set-intersect. 2018-06-12 01:16:42 -04:00
Behdad Esfahbod 11f1f4131b [set] Add is_subset
New API:
+hb_set_is_subset()
2018-06-06 16:47:13 -07:00
Garret Rieger 9a6f9b4d42 [set] add a test demonstrating a bug in hb_set_union. 2018-03-07 09:25:53 +01:00
Ebrahim Byagowi cd28eb9f5d Add -Werror=unused-function check to Travis (#832) 2018-02-24 14:17:54 +03:30
Behdad Esfahbod 694eaf6367 [set] Add backwards iterator
New API:
- hb_set_previous()
- hb_set_previous_range()
2018-02-14 01:00:10 -08:00
Behdad Esfahbod 20b4672754 [set] Fix recent changes
Ouch!

Add tests.
2017-12-02 15:15:50 -08:00
ebraminio 7c6937e7c7 Move all references of old url to the new address (#622) 2017-11-20 14:49:22 -05:00
Behdad Esfahbod cb6c6b0c42 Fix warning
https://github.com/behdad/harfbuzz/commit/49a41dc75931cc2d2f7e74b7801f8cc327039e8e#commitcomment-25203194
2017-10-26 11:43:33 -06:00
Jonathan Kew 7339926525 [test] Extend hb_set test for issue 579 (currently failing) 2017-10-26 12:33:05 -05:00
Jonathan Kew 3d6f7df42a [test] Additional coverage in test_set_iter.
This adds a couple extra entries to the set used, such that iteration
would fail in 1.6.2 due to the bug in hb_set_t::page_t::next().
2017-10-26 12:30:52 -05:00
Behdad Esfahbod 49a41dc759 [test] Add more hb-set tests
https://github.com/behdad/harfbuzz/issues/579
2017-10-25 16:17:45 -06:00
Behdad Esfahbod deed4a48d1 Faster hb_set_t
Fixes https://github.com/behdad/harfbuzz/pull/23
2017-10-15 16:45:33 -03:00
Luis de Bethencourt 1eacde00cc check hb_set_is_emtpy in test-set.c 2014-02-10 13:48:43 -05:00
Behdad Esfahbod 20cbc1f8eb Annotate hb-set a bit; add HB_SET_VALUE_INVALID 2013-09-06 15:31:22 -04:00
Behdad Esfahbod dfbd115e6c [test] Add test for hb_set_get_min() bug
Failing now.

Bug 64476 - Typo in hb_set_t.get_min()
2013-05-14 15:30:17 -04:00
Behdad Esfahbod e81aff9ef7 [tests] Finish test-set.c
All passing now.
2013-01-02 23:22:54 -06:00
Behdad Esfahbod 8165f2765b [tests] Start adding tests for hb-set.h
Fails now.  Fixing.
2013-01-02 22:50:36 -06:00