~ubuntu-branches/ubuntu/vivid/soundscaperenderer/vivid

« back to all changes in this revision

Viewing changes to apf/unit_tests/test_iterator_combinations.cpp

  • Committer: Package Import Robot
  • Author(s): IOhannes m zmölnig (Debian/GNU)
  • Date: 2014-05-08 16:58:09 UTC
  • Revision ID: package-import@ubuntu.com-20140508165809-7tz9dhu5pvo5wy25
Tags: upstream-0.4.1~dfsg
Import upstream version 0.4.1~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 * Copyright © 2012-2014 Institut für Nachrichtentechnik, Universität Rostock *
 
3
 * Copyright © 2006-2012 Quality & Usability Lab,                             *
 
4
 *                       Telekom Innovation Laboratories, TU Berlin           *
 
5
 *                                                                            *
 
6
 * This file is part of the Audio Processing Framework (APF).                 *
 
7
 *                                                                            *
 
8
 * The APF is free software:  you can redistribute it and/or modify it  under *
 
9
 * the terms of the  GNU  General  Public  License  as published by the  Free *
 
10
 * Software Foundation, either version 3 of the License,  or (at your option) *
 
11
 * any later version.                                                         *
 
12
 *                                                                            *
 
13
 * The APF is distributed in the hope that it will be useful, but WITHOUT ANY *
 
14
 * WARRANTY;  without even the implied warranty of MERCHANTABILITY or FITNESS *
 
15
 * FOR A PARTICULAR PURPOSE.                                                  *
 
16
 * See the GNU General Public License for more details.                       *
 
17
 *                                                                            *
 
18
 * You should  have received a copy  of the GNU General Public License  along *
 
19
 * with this program.  If not, see <http://www.gnu.org/licenses/>.            *
 
20
 *                                                                            *
 
21
 *                                 http://AudioProcessingFramework.github.com *
 
22
 ******************************************************************************/
 
23
 
 
24
// Tests for combinations of different iterators.
 
25
 
 
26
#include "apf/iterator.h"  // for *_iterator
 
27
 
 
28
#include "catch/catch.hpp"
 
29
 
 
30
struct three_halves
 
31
{
 
32
  float operator()(int in) { return static_cast<float>(in) * 1.5f; }
 
33
};
 
34
 
 
35
using ii = apf::index_iterator<int>;
 
36
using fii = apf::transform_iterator<ii, three_halves>;
 
37
using si = apf::stride_iterator<ii>;
 
38
using fsi = apf::transform_iterator<si, three_halves>;
 
39
 
 
40
TEST_CASE("iterators/combinations", "Test combinations of iterators")
 
41
{
 
42
 
 
43
SECTION("index_iterator + transform_iterator", "")
 
44
{
 
45
  auto iter = fii(apf::make_index_iterator(2), three_halves());
 
46
  CHECK(*iter == 3.0f);
 
47
}
 
48
 
 
49
SECTION("index_iterator + stride_iterator + transform_iterator", "")
 
50
{
 
51
  auto iter = fsi(si(apf::make_index_iterator(2), 2), three_halves());
 
52
  CHECK(*iter == 3.0f);
 
53
  ++iter;
 
54
  CHECK(*iter == 6.0f);
 
55
 
 
56
  auto iter2 = fsi(si(apf::make_index_iterator(2), -2), three_halves());
 
57
  CHECK(*iter2 == 3.0f);
 
58
  ++iter2;
 
59
  CHECK(*iter2 == 0.0f);
 
60
}
 
61
 
 
62
 
 
63
} // TEST_CASE
 
64
 
 
65
// Settings for Vim (http://www.vim.org/), please do not remove:
 
66
// vim:softtabstop=2:shiftwidth=2:expandtab:textwidth=80:cindent