1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2026 Torgeir Børresen <tb@starkad.no>
//! Original unit tests for the singleton set-id helpers
//! ([`IdSetLexicon::add_singleton`] / [`IdSetLexicon::singleton_value`]) and
//! the encoding convention they guard. This port encodes singleton sets as
//! `-(value + 1)`, while upstream C++ encodes them as the raw value itself —
//! so ported code must never push a raw id as a set id (see BUG.md §2,
//! Phase 5: the `GraphEdgeClipper` emission did exactly that, silently losing
//! all input-edge attribution). Written for this crate, not ported from
//! upstream S2.
use ;
use quickcheck;
/// `singleton_value` is the inverse of `add_singleton`.
/// A singleton id decodes to its one-element set on a *fresh* lexicon — no
/// instance state is required (singletons are encoded inline, never stored).
/// The instance encoder agrees with the instance-free helper for singletons.
/// Singleton ids occupy their own id space: always negative (stored
/// multi-element sets use non-negative ids) and never the empty-set id.
/// The C++-convention trap, as a test: pushing a *raw* non-negative id as a
/// set id does NOT decode to the singleton of that value in this port. Any
/// ported code relying on the C++ "singleton == raw value" encoding must go
/// through `add_singleton` instead.