From 000486e12685d89c04b9f70badee3410b9fc1506 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 22 Dec 2010 04:09:27 +0100 Subject: [PATCH] WIP create empty unit tests for time quantisation/handling --- src/lib/lumitime.hpp | 26 ++---- tests/40components.tests | 17 +++- tests/lib/Makefile.am | 5 +- ...ime-wrapper-test.cpp => lumitime-test.cpp} | 6 +- tests/lib/time/time-formats-test.cpp | 90 +++++++++++++++++++ tests/lib/time/time-quantisation-test.cpp | 90 +++++++++++++++++++ tests/lib/time/time-value-test.cpp | 90 +++++++++++++++++++ 7 files changed, 300 insertions(+), 24 deletions(-) rename tests/lib/{time-wrapper-test.cpp => lumitime-test.cpp} (96%) create mode 100644 tests/lib/time/time-formats-test.cpp create mode 100644 tests/lib/time/time-quantisation-test.cpp create mode 100644 tests/lib/time/time-value-test.cpp diff --git a/src/lib/lumitime.hpp b/src/lib/lumitime.hpp index 5fe942218..88c6a1764 100644 --- a/src/lib/lumitime.hpp +++ b/src/lib/lumitime.hpp @@ -36,27 +36,15 @@ namespace lumiera { /** - * C++ convenience wrapper representing a time value, which could denote - * a temporal position (time point) relative to an (implicit) timeline zero - * point, or it could represent a time interval. + * Lumiera's internal time data. + * Time denotes a time point, specified as opaque value on an + * quasi continuous ("sufficiently precise") internal time scale, relative + * to an (implicit) timeline zero point. The actual implementation relies + * on gavl_time_t (long) values. * - * This wrapper is deliberately kept rather limited as not to be completely - * interchangeable with and integral type. The rationale is that time values - * should be kept separate and tagged as time values. The following is supported: - * - conversions from / to gavl_time_t (which is effectively a int64_t) - * - additions and subtractions of time values - * - multiplication with an integral factor - * - comparisons between time values and gavl_time_t values + * @see lib::time::TimeVar for an number-like time value usable for calculations * - * @todo consider the possible extensions - * - parsing and pretty printing - * - quantising of floating point values - * - conversion to boost::rational - * - define a Framerate type - * - * @note this is currently (10/08) an experimental implementation to ease - * the time handling within C++ code. It is advisable not to use it - * on external interfaces (use gavl_time_t there please). + * @todo it is not clear to which degree Time is mutable... */ class Time : boost::additive @@ -47,7 +47,7 @@ namespace test { /******************************************** * @test sanity of the C++ time wrapper. */ - class TimeWrapper_test : public Test + class LumiTime_test : public Test { virtual void run (Arg arg) @@ -166,7 +166,7 @@ namespace test { /** Register this test class... */ - LAUNCHER (TimeWrapper_test, "unit common"); + LAUNCHER (LumiTime_test, "unit common"); diff --git a/tests/lib/time/time-formats-test.cpp b/tests/lib/time/time-formats-test.cpp new file mode 100644 index 000000000..5a60473ae --- /dev/null +++ b/tests/lib/time/time-formats-test.cpp @@ -0,0 +1,90 @@ +/* + TimeFormats(Test) - timecode handling and formatting + + Copyright (C) Lumiera.org + 2010, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + + +#include "lib/test/run.hpp" +#include "lib/time/timecode.hpp" +#include "lib/util.hpp" + +//#include +//#include +//#include + +//using boost::lexical_cast; +//using util::isnil; +//using std::rand; +//using std::cout; +//using std::endl; + + +namespace lib { +namespace time{ +namespace test{ + + + /******************************************************** + * @test verify handling of grid aligned timecode values. + * - creating timecode values + * - some conversions + * - formatting + */ + class TimeFormats_test : public Test + { + virtual void + run (Arg arg) + { + long refval= isnil(arg)? 1 : lexical_cast (arg[1]); + + Time ref (refval); + + checkBasics (ref); + checkComparisons (ref); + checkComponentAccess(); + } + + + void + checkBasics (Time const& ref) + { + } + + + void + checkComparisons (Time const& ref) + { + } + + + void + checkComponentAccess() + { + } + + }; + + + /** Register this test class... */ + LAUNCHER (TimeFormats_test, "unit common"); + + + +}}} // namespace lib::time::test diff --git a/tests/lib/time/time-quantisation-test.cpp b/tests/lib/time/time-quantisation-test.cpp new file mode 100644 index 000000000..5e6660e2d --- /dev/null +++ b/tests/lib/time/time-quantisation-test.cpp @@ -0,0 +1,90 @@ +/* + TimeQuantisation(Test) - handling of virtually grid aligned time values + + Copyright (C) Lumiera.org + 2010, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + + +#include "lib/test/run.hpp" +#include "lib/time/quantiser.hpp" +#include "lib/util.hpp" + +//#include +//#include +//#include + +//using boost::lexical_cast; +//using util::isnil; +//using std::rand; +//using std::cout; +//using std::endl; + + +namespace lib { +namespace time{ +namespace test{ + + + /******************************************************** + * @test verify handling of time values, time intervals. + * - creating times and time intervals + * - comparisons + * - time arithmetics + */ + class TimeQuantisation_test : public Test + { + virtual void + run (Arg arg) + { + long refval= isnil(arg)? 1 : lexical_cast (arg[1]); + + Time ref (refval); + + checkBasics (ref); + checkComparisons (ref); + checkComponentAccess(); + } + + + void + checkBasics (Time const& ref) + { + } + + + void + checkComparisons (Time const& ref) + { + } + + + void + checkComponentAccess() + { + } + + }; + + + /** Register this test class... */ + LAUNCHER (TimeQuantisation_test, "unit common"); + + + +}}} // namespace lib::time::test diff --git a/tests/lib/time/time-value-test.cpp b/tests/lib/time/time-value-test.cpp new file mode 100644 index 000000000..b40ca5189 --- /dev/null +++ b/tests/lib/time/time-value-test.cpp @@ -0,0 +1,90 @@ +/* + TimeValue(Test) - working with time values and time intervals in C++... + + Copyright (C) Lumiera.org + 2010, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + + +#include "lib/test/run.hpp" +#include "lib/time/timevalue.hpp" +#include "lib/util.hpp" + +//#include +//#include +//#include + +//using boost::lexical_cast; +//using util::isnil; +//using std::rand; +//using std::cout; +//using std::endl; + + +namespace lib { +namespace time{ +namespace test{ + + + /******************************************************** + * @test verify handling of time values, time intervals. + * - creating times and time intervals + * - comparisons + * - time arithmetics + */ + class TimeValue_test : public Test + { + virtual void + run (Arg arg) + { + long refval= isnil(arg)? 1 : lexical_cast (arg[1]); + + Time ref (refval); + + checkBasics (ref); + checkComparisons (ref); + checkComponentAccess(); + } + + + void + checkBasics (Time const& ref) + { + } + + + void + checkComparisons (Time const& ref) + { + } + + + void + checkComponentAccess() + { + } + + }; + + + /** Register this test class... */ + LAUNCHER (TimeValue_test, "unit common"); + + + +}}} // namespace lib::time::test