26 #define BOOST_TEST_MODULE ( trajectorypointflags_test ) 27 #include "boost/test/unit_test.hpp" 42 std::set<util::flags::Index_t>
const& expectedDefined,
43 std::set<util::flags::Index_t>
const& expectedSet
51 BOOST_TEST(flags.
nFlags() == trkflag::maxFlags());
55 i <= trkflag::maxFlags();
58 bool const allocated = (i < trkflag::maxFlags());
59 bool const defined = (expectedDefined.count(i) > 0);
60 bool const set = (expectedSet.count(i) > 0);
62 BOOST_TEST_MESSAGE(
"Testing flag #" << i);
84 BOOST_TEST(flags.
isFlag(i) == allocated);
89 BOOST_TEST(flags.
isDefined(i) == defined);
100 BOOST_TEST(flags.
test(i) ==
set);
105 BOOST_TEST(flags.
get(i) ==
set);
110 BOOST_TEST(flags.
isSet(i) ==
set);
115 BOOST_TEST(flags.
isUnset(i) == !
set);
134 std::set<util::flags::Index_t> expectedDefined, expectedSet;
135 for (
unsigned int i = 0; i < expectedMask.capacity(); ++i) {
136 if (expectedMask.isUndefined(i))
continue;
137 expectedDefined.insert(i);
138 if (expectedMask.isSet(i)) expectedSet.insert(i);
145 std::cout <<
"Default-constructed flags, dump(verbosity=" <<
level <<
"):" 147 flags.dump(std::cout,
level,
" ");
152 BOOST_TEST_MESSAGE(
"Flag check for default constructed object");
164 BOOST_TEST(!flags.isHitIgnored());
169 BOOST_TEST(flags.isPointValid());
174 BOOST_TEST(!flags.isMerged());
179 BOOST_TEST(!flags.isShared());
184 BOOST_TEST(!flags.isDeltaRay());
189 BOOST_TEST(!flags.hasDetectorIssues());
194 BOOST_TEST(!flags.isOtherwiseSuspicious());
199 BOOST_TEST(flags.isExclusive());
204 BOOST_TEST(!flags.isExcludedFromFit());
209 BOOST_TEST(flags.belongsToTrack());
214 BOOST_TEST(!flags.isHitReinterpreted());
219 BOOST_TEST(flags.isIncludedInFit());
224 BOOST_TEST(!flags.isPointFlawed());
229 BOOST_TEST(flags.isPointFlawless());
234 BOOST_TEST(!flags.hasOriginalHitIndex());
239 BOOST_TEST(flags.fromHit() == InvalidHitIndex);
250 std::set<recob::TrajectoryPointFlags::Flag_t>
const expectedBits
251 = { trkflag::NoPoint, trkflag::HitIgnored };
254 (trkflag::NoPoint, trkflag::HitIgnored);
260 (InvalidHitIndex, trkflag::NoPoint, trkflag::HitIgnored);
262 std::set<util::flags::Index_t> expectedDefined;
263 expectedDefined.insert(trkflag::NoPoint.
index());
264 expectedDefined.insert(trkflag::HitIgnored.
index());
265 std::set<util::flags::Index_t> expectedSet = expectedDefined;
271 std::cout <<
"Flag-constructed flags, dump(verbosity=" <<
level <<
"):" 273 flags.dump(std::cout,
level,
" ");
277 BOOST_TEST_MESSAGE(
"Flag check for flag-constructed object");
284 BOOST_TEST(flags.mask() == flagbitmask);
289 BOOST_TEST(!flags.hasOriginalHitIndex());
294 BOOST_TEST(flags.fromHit() == InvalidHitIndex);
308 trkflag::NoPoint, trkflag::Rejected,
312 std::set<util::flags::Index_t> expectedSet;
313 expectedSet.insert(trkflag::NoPoint.
index());
314 expectedSet.insert(trkflag::Rejected.
index());
315 std::set<util::flags::Index_t> expectedDefined = expectedSet;
316 expectedDefined.insert(trkflag::HitIgnored.
index());
318 std::set<Flag_t>
const expectedValues(expectedSet.begin(), expectedSet.end());
319 std::set<Flag_t>
const expectedFlags
320 (expectedDefined.begin(), expectedDefined.end());
328 trkflag::NoPoint + trkflag::Rejected + -trkflag::HitIgnored));
339 std::cout <<
"Bitmask-constructed flags, dump(verbosity=" <<
level <<
"):" 341 flags.dump(std::cout,
level,
" ");
346 BOOST_TEST_MESSAGE(
"Flag check for bitmask-constructed object");
353 BOOST_TEST(flags.mask() == flagbitmask);
359 (flags.isHitIgnored() == (expectedValues.count(trkflag::HitIgnored) > 0));
365 (flags.isPointValid() == (expectedValues.count(trkflag::NoPoint) == 0));
370 BOOST_TEST(flags.hasOriginalHitIndex());
375 BOOST_TEST(flags.fromHit() == 12U);
421 (trkflag::NoPoint, trkflag::Merged);
constexpr bool isFlag(FlagIndex_t flagIndex) const
void TrajectoryPointFlagsTest_DefaultConstructor()
TrajectoryPointFlagTraits flag
Type of flag traits (indices and meaning of flags).
static constexpr Mask_t makeMask(Flags...flags)
Returns a bit mask with only the specified bit set.
bool isSet(Flag_t flag) const
Returns true if the flag exists and is set.
static constexpr Mask_t DefaultFlagsMask()
Flags used in default construction.
typename Mask_t::OutOfRangeError OutOfRangeError
Out-of-range flag index.
void TrajectoryPointFlagsDocumentationTest_makeMask()
bool test(FlagIndex_t index) const
Returns whether the specified flag is set.
void TrajectoryPointFlagsDocumentationTest()
typename Mask_t::FlagNotDefinedError FlagNotDefinedError
Flag not defined.
void TrajectoryPointFlagsTest_FlagsConstructor()
bool get(Flag_t flag) const
Returns whether the specified flag is set.
void TrajectoryPointFlagsDocumentationTest_TrajectoryPointFlags_FromMaskTag_t()
static constexpr HitIndex_t InvalidHitIndex
Value marking an invalid hit index.
Set of flags pertaining a point of the track.
Flags_t::Flag_t Flag_t
Type of single flag.
void TrajectoryPointFlagsDocumentationTest_TrajectoryPointFlags_HitIndex_t_Flags()
bool isUnset(Flag_t flag) const
Returns true if the flag exists and is not set.
BOOST_AUTO_TEST_CASE(TrajectoryPointFlagsTestCase)
constexpr bool isAllocated(FlagIndex_t flagIndex) const
Returns whether there is room for a flag with the specified index.
bool isDefined(Flag_t flag) const
Returns true if the flag has been assigned a value.
Flags_t::FlagIndex_t FlagIndex_t
Type of index of single flag.
void CheckFlagsByIndex(recob::TrajectoryPointFlags const &flags, std::set< util::flags::Index_t > const &expectedDefined, std::set< util::flags::Index_t > const &expectedSet)
void TrajectoryPointFlagsTest_BitmaskConstructor()
Set of flags pertaining a point of the track.
constexpr BitMask< Storage > Unset(Flag_t< Storage > flag)
Returns a bit mask which unsets the specified flag.
QTextStream & endl(QTextStream &s)
constexpr FlagIndex_t nFlags() const
Returns the number of defined flags.