To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

The primary repository for this project is hosted at https://github.com/cannam/constant-q-cpp/ .
This repository is a read-only copy which is updated automatically every hour.

Statistics Download as Zip
| Branch: | Revision:

root / test / TestCQKernel.cpp

History | View | Annotate | Download (1.57 KB)

1
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
2

    
3
#include "cq/CQKernel.h"
4

    
5
#include <cmath>
6
#include <vector>
7
#include <iostream>
8

    
9
using std::vector;
10
using std::cerr;
11
using std::endl;
12

    
13
#define BOOST_TEST_DYN_LINK
14
#define BOOST_TEST_MAIN
15

    
16
#include <boost/test/unit_test.hpp>
17

    
18
static int rate = 123;
19
static int max = 60;
20
static int min = 12;
21
static int bpo = 4;
22

    
23
BOOST_AUTO_TEST_SUITE(TestCQKernel)
24

    
25
// Just some simple tests on kernel construction -- make sure it's the
26
// right size, etc
27

    
28
BOOST_AUTO_TEST_CASE(sampleRate) {
29
    CQParameters params(rate, min, max, bpo);
30
    CQKernel k(params);
31
    BOOST_CHECK_EQUAL(k.getProperties().sampleRate, rate);
32
}
33

    
34
BOOST_AUTO_TEST_CASE(binsPerOctave) {
35
    CQParameters params(rate, min, max, bpo);
36
    CQKernel k(params);
37
    BOOST_CHECK_EQUAL(k.getProperties().binsPerOctave, bpo);
38
}
39

    
40
BOOST_AUTO_TEST_CASE(maxFrequency) {
41
    CQParameters params(rate, min, max, bpo);
42
    CQKernel k(params);
43
    BOOST_CHECK_EQUAL(k.getProperties().maxFrequency, max);
44
}
45

    
46
BOOST_AUTO_TEST_CASE(minFrequency) {
47
    CQParameters params(rate, min, max, bpo);
48
    CQKernel k(params);
49
    BOOST_CHECK_CLOSE(k.getProperties().minFrequency,
50
                      (max / 2.0) * pow(2, 1.0/bpo),
51
                      1e-8);
52
}
53

    
54
BOOST_AUTO_TEST_CASE(atomsPerFrame) {
55
    CQParameters params(rate, min, max, bpo);
56
    CQKernel k(params);
57
    BOOST_CHECK_EQUAL(k.getProperties().atomsPerFrame, 5);
58
}
59

    
60
BOOST_AUTO_TEST_CASE(fftSize) {
61
    CQParameters params(rate, min, max, bpo);
62
    CQKernel k(params);
63
    BOOST_CHECK_EQUAL(k.getProperties().fftSize, 32);
64
}
65

    
66
BOOST_AUTO_TEST_SUITE_END()
67