2022-02-12 19:51:30 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2022-02-12 20:57:35 -05:00
|
|
|
#include "temporal/bbt_time.h"
|
2022-02-21 13:55:44 -05:00
|
|
|
#include "temporal/tempo.h"
|
2022-02-12 19:51:30 -05:00
|
|
|
|
|
|
|
#include "BBTTest.h"
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(BBTTest);
|
|
|
|
|
|
|
|
using namespace Temporal;
|
|
|
|
|
|
|
|
void
|
|
|
|
BBTTest::createTest()
|
|
|
|
{
|
2023-02-15 19:51:28 -05:00
|
|
|
CPPUNIT_ASSERT_THROW_MESSAGE ("- zero-bar BBT_Argument;", BBT_Argument (0, 1, 0), IllegalBBTTimeException);
|
|
|
|
CPPUNIT_ASSERT_THROW_MESSAGE ("- zero-beat BBT_Argument;", BBT_Argument (1, 0, 0), IllegalBBTTimeException);
|
|
|
|
CPPUNIT_ASSERT_THROW_MESSAGE ("- zero-bar-and-beat BBT_Argument;", BBT_Argument (0, 0, 0), IllegalBBTTimeException);
|
2022-02-21 13:55:44 -05:00
|
|
|
|
2023-02-15 19:51:28 -05:00
|
|
|
/* This test checks that BBT_Argument cannot convert ticks to beats etc., so the explicit 1920 ticks remains
|
|
|
|
that in the constructed BBT_Argument, rather than being converted to an additional beat. This has to be true
|
|
|
|
because BBT_Argument has no clue what the meter is.
|
2022-02-21 13:55:44 -05:00
|
|
|
*/
|
2023-02-15 19:51:28 -05:00
|
|
|
BBT_Argument a (1, 1, 1920);
|
|
|
|
CPPUNIT_ASSERT(BBT_Argument (1,2,0) != a);
|
2022-02-21 13:55:44 -05:00
|
|
|
|
2023-02-15 19:51:28 -05:00
|
|
|
/* by contrast, a zero-distance "walk" from that location should return a canonicalized BBT_Argument, which given a 4/4 meter
|
2022-02-21 13:55:44 -05:00
|
|
|
will be 1|2|0
|
|
|
|
*/
|
|
|
|
|
|
|
|
TempoMap::SharedPtr tmap (TempoMap::fetch());
|
|
|
|
BBT_Offset b (0, 0, 0);
|
2023-02-15 19:51:28 -05:00
|
|
|
BBT_Argument r = tmap->bbt_walk (a, b);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(BBT_Argument (1,2,0), r);
|
2022-02-21 13:55:44 -05:00
|
|
|
|
2022-02-12 19:51:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BBTTest::addTest()
|
|
|
|
{
|
2022-02-21 13:55:44 -05:00
|
|
|
TempoMap::SharedPtr tmap (TempoMap::fetch());
|
2023-02-15 19:51:28 -05:00
|
|
|
BBT_Argument a(1,1,0);
|
2022-02-21 13:55:44 -05:00
|
|
|
BBT_Offset b(1,0,0);
|
2023-02-15 19:51:28 -05:00
|
|
|
BBT_Argument r = tmap->bbt_walk (a, b);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(BBT_Argument (2,1,0), r);
|
2022-02-21 13:55:44 -05:00
|
|
|
|
|
|
|
b = BBT_Offset (0, 1, 0);
|
|
|
|
r = tmap->bbt_walk (a, b);
|
2023-02-15 19:51:28 -05:00
|
|
|
CPPUNIT_ASSERT_EQUAL(BBT_Argument (1,2,0), r);
|
2022-02-21 13:55:44 -05:00
|
|
|
|
|
|
|
b = BBT_Offset (0, 0, 1);
|
|
|
|
r = tmap->bbt_walk (a, b);
|
2023-02-15 19:51:28 -05:00
|
|
|
CPPUNIT_ASSERT_EQUAL(BBT_Argument (1,1,1), r);
|
2022-02-21 13:55:44 -05:00
|
|
|
|
|
|
|
b = BBT_Offset (0, 0, ticks_per_beat - 1);
|
|
|
|
r = tmap->bbt_walk (a, b);
|
2023-02-15 19:51:28 -05:00
|
|
|
CPPUNIT_ASSERT_EQUAL(BBT_Argument (1,1,ticks_per_beat - 1), r);
|
2022-02-21 13:55:44 -05:00
|
|
|
|
|
|
|
b = BBT_Offset (0, 0, ticks_per_beat);
|
|
|
|
r = tmap->bbt_walk (a, b);
|
2023-02-15 19:51:28 -05:00
|
|
|
CPPUNIT_ASSERT_EQUAL(BBT_Argument (1,2,0), r);
|
2022-02-21 13:55:44 -05:00
|
|
|
|
|
|
|
b = BBT_Offset (0, 0, ticks_per_beat * 2);
|
|
|
|
r = tmap->bbt_walk (a, b);
|
2023-02-15 19:51:28 -05:00
|
|
|
CPPUNIT_ASSERT_EQUAL(BBT_Argument (1,3,0), r);
|
2022-02-21 13:55:44 -05:00
|
|
|
|
|
|
|
/* assumes 4/4 time */
|
|
|
|
|
|
|
|
b = BBT_Offset (0, 4, 0);
|
|
|
|
r = tmap->bbt_walk (a, b);
|
2023-02-15 19:51:28 -05:00
|
|
|
CPPUNIT_ASSERT_EQUAL(BBT_Argument (2,1,0), r);
|
2022-02-21 13:55:44 -05:00
|
|
|
|
|
|
|
b = BBT_Offset (1, 0, 0);
|
|
|
|
r = tmap->bbt_walk (a, b);
|
2023-02-15 19:51:28 -05:00
|
|
|
CPPUNIT_ASSERT_EQUAL(BBT_Argument (2,1,0), r);
|
2022-02-21 13:55:44 -05:00
|
|
|
|
|
|
|
b = BBT_Offset (0, 0, ticks_per_beat * 4);
|
|
|
|
r = tmap->bbt_walk (a, b);
|
2023-02-15 19:51:28 -05:00
|
|
|
CPPUNIT_ASSERT_EQUAL(BBT_Argument (2,1,0), r);
|
2022-02-21 13:55:44 -05:00
|
|
|
|
2022-02-12 19:51:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BBTTest::subtractTest()
|
|
|
|
{
|
2022-02-21 13:55:44 -05:00
|
|
|
TempoMap::SharedPtr tmap (TempoMap::fetch());
|
2023-02-15 19:51:28 -05:00
|
|
|
BBT_Argument a (1,1,0);
|
2022-02-21 13:55:44 -05:00
|
|
|
BBT_Offset b (1,0,0);
|
2023-02-15 19:51:28 -05:00
|
|
|
BBT_Argument r = tmap->bbt_walk (a, -b);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(BBT_Argument (-1,1,0), r);
|
2022-02-21 13:55:44 -05:00
|
|
|
|
|
|
|
b = BBT_Offset (0, 1, 0);
|
|
|
|
r = tmap->bbt_walk (a, -b);
|
2023-02-15 19:51:28 -05:00
|
|
|
CPPUNIT_ASSERT_EQUAL(BBT_Argument (1,-1,0), r); /* Not sure this is actually the correct answer */
|
2022-02-21 13:55:44 -05:00
|
|
|
|
|
|
|
b = BBT_Offset (0, 0, 1);
|
|
|
|
r = tmap->bbt_walk (a, -b);
|
2023-02-15 19:51:28 -05:00
|
|
|
CPPUNIT_ASSERT_EQUAL(BBT_Argument (1,1,-1), r); /* Not sure this is actually the correct answer */
|
2022-02-21 13:55:44 -05:00
|
|
|
|
|
|
|
b = BBT_Offset (0, 0, ticks_per_beat);
|
|
|
|
r = tmap->bbt_walk (a, -b);
|
2023-02-15 19:51:28 -05:00
|
|
|
CPPUNIT_ASSERT_EQUAL(BBT_Argument (1,1,-ticks_per_beat), r); /* Not sure this is actually the correct answer */
|
2022-02-21 13:55:44 -05:00
|
|
|
|
|
|
|
b = BBT_Offset (0, 0, ticks_per_beat + 1);
|
|
|
|
r = tmap->bbt_walk (a, -b);
|
2023-02-15 19:51:28 -05:00
|
|
|
CPPUNIT_ASSERT_EQUAL(BBT_Argument (1,1,-(ticks_per_beat+1)), r); /* Not sure this is actually the correct answer */
|
2022-02-12 19:51:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BBTTest::multiplyTest()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BBTTest::roundTest()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BBTTest::convertTest()
|
|
|
|
{
|
|
|
|
}
|