Skip to content

Commit

Permalink
SampleBundle.at() testing more interpolation types at whole numbers, …
Browse files Browse the repository at this point in the history
…all pass. issue #70
  • Loading branch information
nwolek committed Jan 3, 2016
1 parent 55b0b29 commit 9ba4b71
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/SampleBundle/SampleBundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,27 +135,42 @@ namespace Jamoma {
}

void testInterpolationAtWholeNumbers() {
int badSampleCountCosine = 0;
int badSampleCountLinear = 0;
int badSampleCountCubic = 0;
int badSampleCountSpline = 0;
SampleBundle test_bundle(2,64);

test_bundle.generate<Generator::UnipolarRamp<Sample>>();

Jamoma::Sample tempCosine;
Jamoma::Sample tempLinear;
Jamoma::Sample tempCubic;
Jamoma::Sample tempSpline;
Jamoma::Sample tempExpected;
for (int i = 0; i < 85; i ++)
{
double d = 3.0 * i / 4.0;

tempCosine = test_bundle.at<Jamoma::Interpolator::Cosine<Sample>>(d);
tempLinear = test_bundle.at<Jamoma::Interpolator::Linear<Sample>>(d);
tempCubic = test_bundle.at<Jamoma::Interpolator::Cubic<Sample>>(d);
tempSpline = test_bundle.at<Jamoma::Interpolator::Spline<Sample>>(d);

if (i % 4 == 0) { // every 4th item should be a whole number we can compare with regular access
tempExpected = test_bundle[0][int(d)];
if (tempCosine != tempExpected) badSampleCountCosine++;
if (tempLinear != tempExpected) badSampleCountLinear++;
if (tempCubic != tempExpected) badSampleCountCubic++;
if (tempSpline != tempExpected) badSampleCountSpline++;
}

}

mTest->TEST_ASSERT("cosine interpolation produces same values as [] operator", badSampleCountCosine == 0);
mTest->TEST_ASSERT("linear interpolation produces same values as [] operator", badSampleCountLinear == 0);
mTest->TEST_ASSERT("cubic interpolation produces same values as [] operator", badSampleCountCubic == 0);
mTest->TEST_ASSERT("spline interpolation produces same values as [] operator", badSampleCountSpline == 0);

}

Expand Down

0 comments on commit 9ba4b71

Please sign in to comment.