ardour
SMFTest.hpp
Go to the documentation of this file.
1 /* This file is part of Evoral.
2  * Copyright(C) 2000-2008 Paul Davis
3  * Author: Hans Baier
4  *
5  * Evoral is free software; you can redistribute it and/or modify it under the
6  * terms of the GNU General Public License as published by the Free Software
7  * Foundation; either version 2 of the License, or(at your option) any later
8  * version.
9  *
10  * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include <cassert>
20 #include <stdint.h>
21 #include <sigc++/sigc++.h>
22 #include <cppunit/TestFixture.h>
23 #include <cppunit/extensions/HelperMacros.h>
24 #include "evoral/types.hpp"
25 #include "evoral/SMF.hpp"
26 #include "SequenceTest.hpp"
27 
28 using namespace Evoral;
29 
30 class TestSMF : public SMF {
31 public:
32  std::string path() const { return _path; }
33 
34  int open(const std::string& path) THROW_FILE_ERROR {
35  _path = path;
36  return SMF::open(path);
37  }
38 
40  return SMF::close();
41  }
42 
43  int read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const {
44  event_id_t id;
45  return SMF::read_event(delta_t, size, buf, &id);
46  }
47 
48 private:
49  std::string _path;
50 };
51 
52 class SMFTest : public CppUnit::TestFixture
53 {
54  CPPUNIT_TEST_SUITE(SMFTest);
55  CPPUNIT_TEST(createNewFileTest);
56  CPPUNIT_TEST(takeFiveTest);
57  CPPUNIT_TEST_SUITE_END();
58 
59 public:
61 
62  void setUp() {
63  type_map = new DummyTypeMap();
64  assert(type_map);
65  seq = new MySequence<Time>(*type_map);
66  assert(seq);
67  }
68 
69  void tearDown() {
70  delete seq;
71  delete type_map;
72  }
73 
74  void createNewFileTest();
75  void takeFiveTest();
76 
77 private:
80 };
81 
int read_event(uint32_t *delta_t, uint32_t *size, uint8_t **buf) const
Definition: OldSMF.cpp:212
int32_t event_id_t
Definition: types.hpp:40
int open(const std::string &path) THROW_FILE_ERROR
Definition: OldSMF.cpp:60
void close() THROW_FILE_ERROR
Definition: SMFTest.hpp:39
Evoral::Beats Time
Definition: SMFTest.hpp:60
void close() THROW_FILE_ERROR
Definition: OldSMF.cpp:96
void setUp()
Definition: SMFTest.hpp:62
void tearDown()
Definition: SMFTest.hpp:69
int open(const std::string &path) THROW_FILE_ERROR
Definition: SMFTest.hpp:34
std::string path() const
Definition: SMFTest.hpp:32
MySequence< Time > * seq
Definition: SMFTest.hpp:79
int read_event(uint32_t *delta_t, uint32_t *size, uint8_t **buf) const
Definition: SMFTest.hpp:43
#define THROW_FILE_ERROR
Definition: SMF.hpp:35
DummyTypeMap * type_map
Definition: SMFTest.hpp:78
std::string _path
Definition: SMFTest.hpp:49