diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2018-06-16 18:05:00 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2018-06-16 18:15:59 +0200 |
commit | 2abc107b24f73b8c4664189c34196d9a27a3e339 (patch) | |
tree | b7067a45f7294dbd143c410bdfb690157c976e3c /test/instrumentparsertest.cc | |
parent | e694a23ab28686ecc0635c2ac8c625e743b89a3b (diff) |
Port the rest of the unittests to DGUnit and remove the CppUnit dependency.
Diffstat (limited to 'test/instrumentparsertest.cc')
-rw-r--r-- | test/instrumentparsertest.cc | 71 |
1 files changed, 32 insertions, 39 deletions
diff --git a/test/instrumentparsertest.cc b/test/instrumentparsertest.cc index 44011e1..2fb81d0 100644 --- a/test/instrumentparsertest.cc +++ b/test/instrumentparsertest.cc @@ -24,29 +24,22 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <cppunit/extensions/HelperMacros.h> +#include "dgunit.h" #include <instrumentparser.h> #include "scopedfile.h" class InstrumentParserTest - : public CppUnit::TestFixture + : public DGUnit { - CPPUNIT_TEST_SUITE(InstrumentParserTest); - CPPUNIT_TEST(testTest); - CPPUNIT_TEST_SUITE_END(); - - Settings settings; - Random rand; - public: - void setUp() + InstrumentParserTest() { + DGUNIT_TEST(InstrumentParserTest::testTest); } - void tearDown() - { - } + Settings settings; + Random rand; //! This just creates some drumkit. void testTest() @@ -71,45 +64,45 @@ public: "</instrument>"); Instrument instrument(settings, rand); InstrumentParser parser(instrument, settings); - CPPUNIT_ASSERT_EQUAL(0, parser.parseFile(scoped_file.filename())); + DGUNIT_ASSERT_EQUAL(0, parser.parseFile(scoped_file.filename())); - CPPUNIT_ASSERT_EQUAL(std::string(""), instrument._group); - CPPUNIT_ASSERT_EQUAL(std::string("Snare"), instrument._name); - CPPUNIT_ASSERT_EQUAL(std::string(""), instrument._description); + DGUNIT_ASSERT_EQUAL(std::string(""), instrument._group); + DGUNIT_ASSERT_EQUAL(std::string("Snare"), instrument._name); + DGUNIT_ASSERT_EQUAL(std::string(""), instrument._description); - CPPUNIT_ASSERT(VersionStr("2.0.0") == instrument.version); + DGUNIT_ASSERT(VersionStr("2.0.0") == instrument.version); // NOTE: instrument.samples are the sample map belonging to version 1.0 - CPPUNIT_ASSERT_EQUAL(std::size_t(2), instrument.samplelist.size()); + DGUNIT_ASSERT_EQUAL(std::size_t(2), instrument.samplelist.size()); { const auto& sample = *instrument.samplelist[0]; - CPPUNIT_ASSERT_EQUAL(std::string("Snare-1"), sample.name); - CPPUNIT_ASSERT_EQUAL(0.00985718f, sample.power); - CPPUNIT_ASSERT_EQUAL(std::size_t(4), sample.audiofiles.size()); + DGUNIT_ASSERT_EQUAL(std::string("Snare-1"), sample.name); + DGUNIT_ASSERT_EQUAL(0.00985718f, sample.power); + DGUNIT_ASSERT_EQUAL(std::size_t(4), sample.audiofiles.size()); for(const auto& audiofile : sample.audiofiles) { - CPPUNIT_ASSERT_EQUAL(std::string("/tmp/1-Snare.wav"), audiofile.second->filename); + DGUNIT_ASSERT_EQUAL(std::string("/tmp/1-Snare.wav"), audiofile.second->filename); switch(audiofile.second->filechannel) { // NOTE: Channel numbers are zero based - they are 1 based in the xml case 0: - CPPUNIT_ASSERT_EQUAL(std::string("AmbLeft"), + DGUNIT_ASSERT_EQUAL(std::string("AmbLeft"), audiofile.second->instrument_channel->name); break; case 1: - CPPUNIT_ASSERT_EQUAL(std::string("AmbRight"), + DGUNIT_ASSERT_EQUAL(std::string("AmbRight"), audiofile.second->instrument_channel->name); break; case 11: - CPPUNIT_ASSERT_EQUAL(std::string("SnareBottom"), + DGUNIT_ASSERT_EQUAL(std::string("SnareBottom"), audiofile.second->instrument_channel->name); break; case 12: - CPPUNIT_ASSERT_EQUAL(std::string("SnareTop"), + DGUNIT_ASSERT_EQUAL(std::string("SnareTop"), audiofile.second->instrument_channel->name); break; default: - CPPUNIT_ASSERT(false); + DGUNIT_ASSERT(false); break; } } @@ -117,39 +110,39 @@ public: { const auto& sample = *instrument.samplelist[1]; - CPPUNIT_ASSERT_EQUAL(std::string("Snare-2"), sample.name); - CPPUNIT_ASSERT_EQUAL(0.0124808f, sample.power); - CPPUNIT_ASSERT_EQUAL(std::size_t(4), sample.audiofiles.size()); + DGUNIT_ASSERT_EQUAL(std::string("Snare-2"), sample.name); + DGUNIT_ASSERT_EQUAL(0.0124808f, sample.power); + DGUNIT_ASSERT_EQUAL(std::size_t(4), sample.audiofiles.size()); for(const auto& audiofile : sample.audiofiles) { - CPPUNIT_ASSERT_EQUAL(std::string("/tmp/2-Snare.wav"), audiofile.second->filename); + DGUNIT_ASSERT_EQUAL(std::string("/tmp/2-Snare.wav"), audiofile.second->filename); switch(audiofile.second->filechannel) { // NOTE: Channel numbers are zero based - they are 1 based in the xml case 0: - CPPUNIT_ASSERT_EQUAL(std::string("AmbLeft"), + DGUNIT_ASSERT_EQUAL(std::string("AmbLeft"), audiofile.second->instrument_channel->name); break; case 1: - CPPUNIT_ASSERT_EQUAL(std::string("AmbRight"), + DGUNIT_ASSERT_EQUAL(std::string("AmbRight"), audiofile.second->instrument_channel->name); break; case 11: - CPPUNIT_ASSERT_EQUAL(std::string("SnareBottom"), + DGUNIT_ASSERT_EQUAL(std::string("SnareBottom"), audiofile.second->instrument_channel->name); break; case 12: - CPPUNIT_ASSERT_EQUAL(std::string("SnareTop"), + DGUNIT_ASSERT_EQUAL(std::string("SnareTop"), audiofile.second->instrument_channel->name); break; default: - CPPUNIT_ASSERT(false); + DGUNIT_ASSERT(false); break; } } } -//CPPUNIT_ASSERT(ref.samples.values == instrument.samples.values); +//DGUNIT_ASSERT(ref.samples.values == instrument.samples.values); //std::vector<Sample*> samplelist; //std::deque<InstrumentChannel> instrument_channels; // @@ -162,4 +155,4 @@ public: }; // Registers the fixture into the 'registry' -CPPUNIT_TEST_SUITE_REGISTRATION(InstrumentParserTest); +static InstrumentParserTest test; |