temporal: add & use a couple of TempMap methods for unit testing

This commit is contained in:
Paul Davis 2025-12-27 11:36:30 -07:00
parent f742ef661b
commit f1b80cdbe1
3 changed files with 37 additions and 0 deletions

View file

@ -2614,6 +2614,37 @@ TempoMap::dump (std::ostream& ostr) const
ostr << "------------\n\n\n";
}
Points::size_type
TempoMap::count_tempos_in_points () const
{
Points::size_type n = 0;
for (Points::const_iterator p = _points.begin(); p != _points.end(); ++p) {
if (dynamic_cast<MusicTimePoint const *> (&(*p))) {
/* ignore */
} else if (dynamic_cast<TempoPoint const *> (&(*p))) {
++n;
}
}
return n;
}
Points::size_type
TempoMap::count_meters_in_points () const
{
Points::size_type n = 0;
for (Points::const_iterator p = _points.begin(); p != _points.end(); ++p) {
if (dynamic_cast<MusicTimePoint const *> (&(*p))) {
/* ignore */
} else if (dynamic_cast<MeterPoint const *> (&(*p))) {
++n;
}
}
return n;
}
template<class const_traits_t> typename const_traits_t::iterator_type
TempoMap::_get_tempo_and_meter (typename const_traits_t::tempo_point_type & tp,
typename const_traits_t::meter_point_type & mp,

View file

@ -741,6 +741,10 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible
static thread_local SharedPtr _tempo_map_p;
static SerializedRCUManager<TempoMap> _map_mgr;
static bool fetch_condition ();
public:
/* These are only for use in unit tests */
Points::size_type count_tempos_in_points() const;
Points::size_type count_meters_in_points() const;
public:
LIBTEMPORAL_API static void init ();

View file

@ -50,6 +50,8 @@ TempoMapTest::addRemoveTest()
tmap->dump (std::cout);
CPPUNIT_ASSERT (tmap->tempo_at (BBT_Argument (8, 1, 0)).note_types_per_minute() == Tempo (64, 4).note_types_per_minute());
CPPUNIT_ASSERT (tmap->count_tempos_in_points () == 3);
CPPUNIT_ASSERT (tmap->count_meters_in_points () == 3);
tmap->abort_update ();
}