grid asset passes first basic unit test!

This commit is contained in:
Fischlurch 2011-01-15 14:07:25 +01:00
parent 8bc5bf88c9
commit a70376dc4b
4 changed files with 28 additions and 10 deletions

View file

@ -120,7 +120,7 @@ namespace meta {
*/
Builder(string const& nameID ="")
: id_(nameID)
, fps_(0)
, fps_(1)
, origin_(TimeValue(0))
, predecessor_()
{ }

View file

@ -26,6 +26,7 @@
#include "proc/asset/meta.hpp"
#include "proc/asset/meta/time-grid.hpp"
#include "lib/time/timevalue.hpp"
//#include "proc/asset/entry-id.hpp"
//#include "lib/p.hpp"
//#include "proc/assetmanager.hpp"
@ -37,6 +38,7 @@
//#include "lib/symbol.hpp"
//#include <tr1/unordered_map>
#include <boost/rational.hpp>
//#include <iostream>
//#include <string>
@ -46,6 +48,7 @@
//using util::and_all;
//using util::for_each;
//using util::isnil;
using boost::rational_cast;
using lib::test::randStr;
//using lib::Literal;
//using lib::Symbol;
@ -60,14 +63,18 @@ namespace asset {
namespace meta {
namespace test {
using namespace lib::time;
typedef Builder<TimeGrid> GridBuilder;
typedef EntryID<TimeGrid> GridID;
namespace { // Test definitions...
Time testOrigin (12,23);
FrameRate testFps (5,4);
const Time testOrigin (12,34);
const FrameRate testFps (5,6);
const uint MAX_FRAMES = 1000;
const uint DIRT_GRAIN = 50;
}
@ -98,17 +105,28 @@ namespace test {
GridID myGrID (randStr(8));
GridBuilder spec = asset::Meta::create (myGrID);
CHECK (!spec.fps_);
CHECK (spec.origin_ == Time(0));
CHECK ( spec.fps_ == 1);
CHECK ( spec.origin_ == Time(0));
CHECK (!spec.predecessor_);
spec.fps_ = testFps;
spec.fps_ = testFps;
spec.origin_ = testOrigin;
PGrid myGrid = spec.commit();
CHECK (myGrid);
UNIMPLEMENTED ("the basic Grid API, so we can actually check anything");
// now verify the grid
// by performing some conversions...
int randomFrame = (rand() % MAX_FRAMES);
Time point (myGrid->timeOf (randomFrame));
CHECK (point == testOrigin + randomFrame * testFps.duration());
uint fract = rand() % DIRT_GRAIN;
FSecs dirt = rational_cast<FSecs> (1 / testFps / fract);
Time dirty(point + Time(dirt));
CHECK (point == testOrigin + myGrid->gridAlign(dirty));
}

View file

@ -40,7 +40,7 @@ namespace test{
namespace {
const uint MAX_FRAMES = 25*500;
const uint MAX_DIRT = 50;
const uint DIRT_GRAIN = 50;
const FSecs F25(1,25); // duration of one PAL frame
}
@ -82,7 +82,7 @@ namespace test{
FixedFrameQuantiser fixQ(25);
uint frames = (rand() % MAX_FRAMES);
FSecs dirt = (F25 / (rand() % MAX_DIRT));
FSecs dirt = (F25 / (rand() % DIRT_GRAIN));
Time rawTime = dirt + frames*F25;

View file

@ -82,7 +82,7 @@ namespace test{
FrameNr count(qVal); // materialise this quantised time into..
int n = count; // frame count, accessible as plain number
CHECK (Time(FSecs(n-1, 25)) < org); // verify quantisation: the original time
CHECK (Time(FSecs(n-1, 25)) <= org); // verify quantisation: the original time
CHECK (org < Time(FSecs(n+1, 25))); // is properly bracketed by (n-1, n+2)
}