mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-16 11:46:25 +01:00
* evoral: First productive test environment
git-svn-id: svn://localhost/ardour2/branches/3.0@4495 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
43fdd21557
commit
d1f9f35d31
4 changed files with 94 additions and 82 deletions
|
|
@ -1,84 +1,17 @@
|
||||||
#include <evoral/Sequence.hpp>
|
#include "sequence.hpp"
|
||||||
#include <evoral/TypeMap.hpp>
|
#include <cassert>
|
||||||
|
|
||||||
#include <cppunit/TestFixture.h>
|
CPPUNIT_TEST_SUITE_REGISTRATION( SequenceTest );
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
|
||||||
|
|
||||||
#include <cppunit/CompilerOutputter.h>
|
void
|
||||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
SequenceTest::createTest (void)
|
||||||
#include <cppunit/TestResult.h>
|
|
||||||
#include <cppunit/TestResultCollector.h>
|
|
||||||
#include <cppunit/TestRunner.h>
|
|
||||||
#include <cppunit/BriefTestProgressListener.h>
|
|
||||||
|
|
||||||
using namespace Evoral;
|
|
||||||
|
|
||||||
class DummyTypeMap : public TypeMap {
|
|
||||||
public:
|
|
||||||
virtual ~DummyTypeMap() {}
|
|
||||||
|
|
||||||
virtual bool type_is_midi(uint32_t type) const {return true;}
|
|
||||||
|
|
||||||
virtual uint8_t parameter_midi_type(const Parameter& param) const {return 0;}
|
|
||||||
|
|
||||||
virtual uint32_t midi_event_type(uint8_t status) const {return 0;}
|
|
||||||
|
|
||||||
virtual bool is_integer(const Evoral::Parameter& param) const {return true;}
|
|
||||||
|
|
||||||
virtual Parameter new_parameter(uint32_t type, uint8_t channel, uint32_t id) const {return Parameter(type, channel, id);}
|
|
||||||
|
|
||||||
virtual std::string to_symbol(const Parameter& param) const {return "foo";}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename Time>
|
|
||||||
class MySequence : public Sequence<Time> {
|
|
||||||
public:
|
|
||||||
MySequence(DummyTypeMap&map, int size) : Sequence<Time>(map, size) {}
|
|
||||||
|
|
||||||
boost::shared_ptr<Control> control_factory(const Parameter& param) {return boost::shared_ptr<Control>();}
|
|
||||||
};
|
|
||||||
|
|
||||||
class SequenceTest : public CPPUNIT_NS::TestFixture
|
|
||||||
{
|
{
|
||||||
CPPUNIT_TEST_SUITE (SequenceTest);
|
DummyTypeMap type_map;
|
||||||
CPPUNIT_TEST (createTest);
|
MySequence<double> seq(type_map, 100);
|
||||||
CPPUNIT_TEST_SUITE_END ();
|
|
||||||
|
|
||||||
public:
|
CPPUNIT_ASSERT_EQUAL(size_t(0), seq.sysexes().size());
|
||||||
void setUp (void) {
|
CPPUNIT_ASSERT_EQUAL(size_t(100), seq.notes().size());
|
||||||
Glib::thread_init();
|
CPPUNIT_ASSERT(seq.notes().begin() != seq.notes().end());
|
||||||
}
|
|
||||||
|
|
||||||
void tearDown (void);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void createTest (void) {
|
|
||||||
DummyTypeMap type_map;
|
|
||||||
MySequence<double> s(type_map, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
|
|
||||||
CPPUNIT_NS::TestResult testresult;
|
|
||||||
|
|
||||||
CPPUNIT_NS::TestResultCollector collectedresults;
|
|
||||||
testresult.addListener (&collectedresults);
|
|
||||||
|
|
||||||
CPPUNIT_NS::BriefTestProgressListener progress;
|
|
||||||
testresult.addListener (&progress);
|
|
||||||
|
|
||||||
CPPUNIT_NS::TestRunner testrunner;
|
|
||||||
testrunner.addTest (CPPUNIT_NS::TestFactoryRegistry::getRegistry ().makeTest ());
|
|
||||||
testrunner.run (testresult);
|
|
||||||
|
|
||||||
CPPUNIT_NS::CompilerOutputter compileroutputter (&collectedresults, std::cerr);
|
|
||||||
compileroutputter.write ();
|
|
||||||
|
|
||||||
return collectedresults.wasSuccessful () ? 0 : 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
48
libs/evoral/test/sequence.hpp
Normal file
48
libs/evoral/test/sequence.hpp
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
#include <cppunit/TestFixture.h>
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
|
#include <evoral/Sequence.hpp>
|
||||||
|
#include <evoral/TypeMap.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace Evoral;
|
||||||
|
|
||||||
|
class DummyTypeMap : public TypeMap {
|
||||||
|
public:
|
||||||
|
virtual ~DummyTypeMap() {}
|
||||||
|
|
||||||
|
virtual bool type_is_midi(uint32_t type) const {return true;}
|
||||||
|
|
||||||
|
virtual uint8_t parameter_midi_type(const Parameter& param) const {return 0;}
|
||||||
|
|
||||||
|
virtual uint32_t midi_event_type(uint8_t status) const {return 0;}
|
||||||
|
|
||||||
|
virtual bool is_integer(const Evoral::Parameter& param) const {return true;}
|
||||||
|
|
||||||
|
virtual Parameter new_parameter(uint32_t type, uint8_t channel, uint32_t id) const {return Parameter(type, channel, id);}
|
||||||
|
|
||||||
|
virtual std::string to_symbol(const Parameter& param) const {return "foo";}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Time>
|
||||||
|
class MySequence : public Sequence<Time> {
|
||||||
|
public:
|
||||||
|
MySequence(DummyTypeMap&map, int size) : Sequence<Time>(map, size) {}
|
||||||
|
|
||||||
|
boost::shared_ptr<Control> control_factory(const Parameter& param) {return boost::shared_ptr<Control>();}
|
||||||
|
};
|
||||||
|
|
||||||
|
class SequenceTest : public CppUnit::TestFixture
|
||||||
|
{
|
||||||
|
CPPUNIT_TEST_SUITE (SequenceTest);
|
||||||
|
CPPUNIT_TEST (createTest);
|
||||||
|
CPPUNIT_TEST_SUITE_END ();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setUp (void) { Glib::thread_init(); }
|
||||||
|
void tearDown (void) {}
|
||||||
|
|
||||||
|
void createTest (void);
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
28
libs/evoral/test/testrunner.cpp
Normal file
28
libs/evoral/test/testrunner.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include <cppunit/CompilerOutputter.h>
|
||||||
|
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||||
|
#include <cppunit/TestResult.h>
|
||||||
|
#include <cppunit/TestResultCollector.h>
|
||||||
|
#include <cppunit/TestRunner.h>
|
||||||
|
#include <cppunit/BriefTestProgressListener.h>
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
CppUnit::TestResult testresult;
|
||||||
|
|
||||||
|
CppUnit::TestResultCollector collectedresults;
|
||||||
|
testresult.addListener (&collectedresults);
|
||||||
|
|
||||||
|
CppUnit::BriefTestProgressListener progress;
|
||||||
|
testresult.addListener (&progress);
|
||||||
|
|
||||||
|
CppUnit::TestRunner testrunner;
|
||||||
|
testrunner.addTest (CppUnit::TestFactoryRegistry::getRegistry ().makeTest ());
|
||||||
|
testrunner.run (testresult);
|
||||||
|
|
||||||
|
CppUnit::CompilerOutputter compileroutputter (&collectedresults, std::cerr);
|
||||||
|
compileroutputter.write ();
|
||||||
|
|
||||||
|
return collectedresults.wasSuccessful () ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
@ -28,7 +28,7 @@ def configure(conf):
|
||||||
autowaf.check_tool(conf, 'compiler_cxx')
|
autowaf.check_tool(conf, 'compiler_cxx')
|
||||||
autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.14.0', mandatory=True)
|
autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.14.0', mandatory=True)
|
||||||
autowaf.check_pkg(conf, 'gthread-2.0', uselib_store='GTHREAD', atleast_version='2.14.0', mandatory=True)
|
autowaf.check_pkg(conf, 'gthread-2.0', uselib_store='GTHREAD', atleast_version='2.14.0', mandatory=True)
|
||||||
autowaf.check_pkg(conf, 'cppunit', uselib_store='CPPUNIT', atleast_version='1.12.0', mandatory=True)
|
autowaf.check_pkg(conf, 'cppunit', uselib_store='CPPUNIT', atleast_version='1.12.0', mandatory=False)
|
||||||
|
|
||||||
def build(bld):
|
def build(bld):
|
||||||
# Headers
|
# Headers
|
||||||
|
|
@ -62,11 +62,14 @@ def build(bld):
|
||||||
|
|
||||||
# Unit tests
|
# Unit tests
|
||||||
obj = bld.new_task_gen('cxx', 'program')
|
obj = bld.new_task_gen('cxx', 'program')
|
||||||
obj.source = 'test/sequence.cpp'
|
obj.source = '''
|
||||||
|
test/sequence.cpp
|
||||||
|
test/testrunner.cpp
|
||||||
|
'''
|
||||||
obj.includes = ['.', './src']
|
obj.includes = ['.', './src']
|
||||||
obj.uselib_local = 'libevoral'
|
obj.uselib_local = 'libevoral'
|
||||||
obj.uselib = 'CPPUNIT'
|
obj.uselib = 'CPPUNIT'
|
||||||
obj.target = 'sequence'
|
obj.target = 'run-tests'
|
||||||
obj.install_path = ''
|
obj.install_path = ''
|
||||||
|
|
||||||
def shutdown():
|
def shutdown():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue