Jamoma API  0.6.0.a19
TTThru.test.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspEffectsLib
4  *
5  * @brief Unit tests for #TTThru
6  *
7  * @authors Timothy Place, Trond Lossius
8  *
9  * @copyright Copyright © 2011, Timothy Place @n
10  * License: This code is licensed under the terms of the "New BSD License" @n
11  * http://creativecommons.org/licenses/BSD/
12  */
13 
14 
15 #include "TTThru.h"
16 
17 
18 TTErr TTThru::test(TTValue& returnedTestInfo)
19 {
20  int errorCount = 0;
21  int testAssertionCount = 0;
22 
23  // create stereo audio signals
24  TTAudio input(2);
25  TTAudio output(2);
26 
27  input.allocWithVectorSize(64);
28  output.allocWithVectorSize(64);
29 
30  for (int i=0; i<64; i++)
31  input.rawSamples()[0][i] = TTRandom64();
32 
33  this->process(input, output);
34 
35  int validSampleCount = 0;
36 
37  for (int channel=0; channel<2; channel++) {
38  TTSampleValuePtr inSamples = input.rawSamples()[channel];
39  TTSampleValuePtr outSamples = output.rawSamples()[channel];
40 
41  for (int i=0; i<64; i++) {
42  validSampleCount += TTTestFloatEquivalence(inSamples[i], outSamples[i]);
43  }
44  }
45  TTTestAssertion("input samples accurately copied to output samples",
46  validSampleCount == 128, // 64 * 2 channels
47  testAssertionCount,
48  errorCount);
49  TTTestLog("Number of bad samples: %i", 128-validSampleCount);
50 
51  // Wrap up the test results to pass back to whoever called this test
52  return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);
53 }
TTErr test(TTValue &returnedTestInfo)
Unit testing.
Definition: TTThru.test.cpp:18
TTErr process(TTAudioSignal &in, TTAudioSignal &out)
Process the input signal, resulting in an output signal.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
TTThru pass an input signal to the output unchanged.
Wrap TTAudioSignal instances for convenience.
Definition: TTAudioObject.h:25
TTFOUNDATION_EXPORT TTFloat64 TTRandom64()
Produces a random-valued 64-bit floating-point number in the range [0.0, 1.0].
Definition: TTBase.cpp:611