-Updated tests, updated QUnit

This commit is contained in:
Harry van Haaren 2013-09-17 12:24:58 +01:00
parent a3020cf1e2
commit 827b4a1f14
3 changed files with 30 additions and 9 deletions

View file

@ -170,6 +170,9 @@ void LooperClip::record(int count, float* L, float* R)
sprintf (buffer, "LooperClip t %i, s %i, Error: out of mem!",track, scene ); sprintf (buffer, "LooperClip t %i, s %i, Error: out of mem!",track, scene );
EventGuiPrint e( buffer ); EventGuiPrint e( buffer );
writeToGuiRingbuffer( &e ); writeToGuiRingbuffer( &e );
#ifdef BUILD_TESTS
LUPPP_WARN("%s","buffer has no space");
#endif
break; break;
} }

View file

@ -15,7 +15,7 @@ extern Jack* jack;
int GridLogic::runTests() int GridLogic::runTests()
{ {
QUnit::UnitTest qunit( QUnit::normal ); QUnit::UnitTest qunit( QUnit::normal, true );
int t = 0; int t = 0;
int s = 0; int s = 0;
LooperClip* lc = jack->getLooper( t )->getClip( s ); LooperClip* lc = jack->getLooper( t )->getClip( s );
@ -35,6 +35,10 @@ int GridLogic::runTests()
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_RECORD_QUEUED ); QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_RECORD_QUEUED );
jack->getGridLogic()->bar(); jack->getGridLogic()->bar();
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_RECORDING ); QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_RECORDING );
float buffer[64];
lc->record(64, &buffer[0], &buffer[0]);
// recording -> playing // recording -> playing
jack->getGridLogic()->pressed( t, s ); jack->getGridLogic()->pressed( t, s );
jack->getGridLogic()->released( t, s ); jack->getGridLogic()->released( t, s );

View file

@ -25,6 +25,8 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <sstream>
#include <cstdlib>
#include <libgen.h> #include <libgen.h>
using namespace std; using namespace std;
@ -53,7 +55,7 @@ namespace QUnit {
class UnitTest { class UnitTest {
public: public:
UnitTest( int verboseLevel ); UnitTest( int verboseLevel, bool openFail = false );
~UnitTest(); ~UnitTest();
void verboseLevel(int level); void verboseLevel(int level);
@ -71,10 +73,12 @@ namespace QUnit {
int verboseLevel_; int verboseLevel_;
int errors_; int errors_;
int tests_; int tests_;
bool openFileOnFail;
}; };
inline UnitTest::UnitTest( int verboseLevel) inline UnitTest::UnitTest( int verboseLevel, bool openFail )
: verboseLevel_(verboseLevel) , errors_(0) , tests_(0) { : verboseLevel_(verboseLevel) , errors_(0) , tests_(0), openFileOnFail(openFail) {
} }
inline UnitTest::~UnitTest() { inline UnitTest::~UnitTest() {
@ -123,12 +127,22 @@ namespace QUnit {
char* baseFile = strdup(file); char* baseFile = strdup(file);
cout << basename(baseFile) << " " << line << " : "; cout << basename(baseFile) << " " << line << " : ";
free( baseFile ); free( baseFile );
if ( ok ) { if ( ok )
cout << QUNIT_COLOUR_PASS; {
} else { cout << QUNIT_COLOUR_PASS << "OK";
cout << QUNIT_COLOUR_ERROR;
} }
cout << ( ok ? "OK" : "FAILED" ) << QUNIT_COLOUR_RESET << " : "; else
{
cout << QUNIT_COLOUR_ERROR << "FAILED";
if ( openFileOnFail )
{
std::stringstream s;
s << "geany" << file << " --line " << line;
system( s.str().c_str() );
}
}
cout << QUNIT_COLOUR_RESET << " : ";
if( compare ) { if( compare ) {
const std::string cmp = ( result ? "==" : "!=" ); const std::string cmp = ( result ? "==" : "!=" );
cout << "compare {" << str1 << "} " << cmp << " {" << str2 << "} " cout << "compare {" << str1 << "} " << cmp << " {" << str2 << "} "