blob: e685361c88e800c4251a1090407c2dcf9a66ccd9 (
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
#include <cppunit/extensions/HelperMacros.h>
#include "../src/memchecker.h"
#include "../src/drumkit.h"
#include "../src/drumkitparser.h"
class MemCheckerTest
: public CppUnit::TestFixture
, public MemChecker
{
CPPUNIT_TEST_SUITE(MemCheckerTest);
CPPUNIT_TEST(small_drumkit);
CPPUNIT_TEST(huge_drumkit);
CPPUNIT_TEST(correct_size);
CPPUNIT_TEST(check_free_ram);
CPPUNIT_TEST_SUITE_END();
private:
Settings settings;
DrumKit kit;
Random random;
const std::string small_kit_path = "kit/small_kit.xml";
const std::string huge_kit_path = "kit/huge_kit.xml";
const std::string audiofile = "kit/ride-multi-channel.wav";
public:
void setUp()
{
kit.clear();
}
void tearDown()
{}
void small_drumkit()
{
DrumKitParser parser(settings, kit, random);
CPPUNIT_ASSERT(!parser.parseFile(small_kit_path));
CPPUNIT_ASSERT(enoughFreeMemory(kit));
}
void huge_drumkit()
{
DrumKitParser parser(settings, kit, random);
CPPUNIT_ASSERT(!parser.parseFile(huge_kit_path));
CPPUNIT_ASSERT(!enoughFreeMemory(kit));
}
void correct_size()
{
uint64_t bytes_per_channel = 2199332;
CPPUNIT_ASSERT_EQUAL(bytes_per_channel, calcBytesPerChannel(audiofile));
DrumKitParser parser(settings, kit, random);
CPPUNIT_ASSERT(!parser.parseFile(huge_kit_path));
uint64_t needed_memory = 71478290000;
CPPUNIT_ASSERT_EQUAL(needed_memory, calcNeededMemory(kit));
}
void check_free_ram()
{
uint64_t free_memory = calcFreeMemory();
uint64_t min_free_memory = 1000;
uint64_t max_free_memory = 50000000000;
CPPUNIT_ASSERT(free_memory >= min_free_memory && free_memory <= max_free_memory);
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(MemCheckerTest);
|