summaryrefslogtreecommitdiff
path: root/libs/evoral/test/SMFTest.hpp
blob: d3f01c3607c64eb4b9c36c08b3ecbe3da9a6660f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
 * Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
 * Copyright (C) 2009-2016 David Robillard <d@drobilla.net>
 * Copyright (C) 2009 Hans Baier <hansfbaier@googlemail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include <cassert>
#include <stdint.h>
#include <sigc++/sigc++.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include "temporal/beats.h"
#include "evoral/SMF.hpp"
#include "SequenceTest.hpp"

using namespace Evoral;

class TestSMF : public SMF {
public:
	std::string path() const { return _path; }

	int open(const std::string& path) {
		_path = path;
		return SMF::open(path);
	}

	void close() {
		return SMF::close();
	}

	int read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const {
		event_id_t id;
		return SMF::read_event(delta_t, size, buf, &id);
	}

private:
	std::string  _path;
};

class SMFTest : public CppUnit::TestFixture
{
	CPPUNIT_TEST_SUITE(SMFTest);
	CPPUNIT_TEST(createNewFileTest);
	CPPUNIT_TEST(takeFiveTest);
	CPPUNIT_TEST(writeTest);
	CPPUNIT_TEST_SUITE_END();

public:
	typedef Temporal::Beats Time;

	void setUp() {
		type_map = new DummyTypeMap();
		assert(type_map);
		seq = new MySequence<Time>(*type_map);
		assert(seq);
	}

	void tearDown() {
		delete seq;
		delete type_map;
	}

	void createNewFileTest();
	void takeFiveTest();
	void writeTest();

private:
	DummyTypeMap*     type_map;
	MySequence<Time>* seq;
};