mpd/test/test_mixramp.cxx

67 lines
1.2 KiB
C++
Raw Normal View History

/*
* Unit tests for mixramp_interpolate()
*/
2015-08-15 15:55:46 +02:00
#include "player/CrossFade.cxx"
2018-10-16 19:01:13 +02:00
#include <gtest/gtest.h>
#include <string.h>
2018-10-16 19:01:13 +02:00
TEST(MixRamp, Interpolate)
{
2018-10-16 19:01:13 +02:00
const char *input = "1.0 0.00;3.0 0.10;6.0 2.50;";
char *foo = strdup(input);
EXPECT_NEAR(0.,
2018-10-16 19:01:13 +02:00
mixramp_interpolate(foo, 0).count(),
0.05);
free(foo);
foo = strdup(input);
EXPECT_NEAR(0.,
2018-10-16 19:01:13 +02:00
mixramp_interpolate(foo, 1).count(),
0.005);
free(foo);
foo = strdup(input);
EXPECT_NEAR(0.1,
2018-10-16 19:01:13 +02:00
mixramp_interpolate(foo, 3).count(),
0.005);
free(foo);
foo = strdup(input);
EXPECT_NEAR(2.5,
2018-10-16 19:01:13 +02:00
mixramp_interpolate(foo, 6).count(),
0.01);
free(foo);
foo = strdup(input);
EXPECT_LT(mixramp_interpolate(foo, 6.1), FloatDuration::zero());
free(foo);
foo = strdup(input);
EXPECT_NEAR(0.05,
2018-10-16 19:01:13 +02:00
mixramp_interpolate(foo, 2).count(),
0.05);
free(foo);
foo = strdup(input);
EXPECT_NEAR(1.3,
2018-10-16 19:01:13 +02:00
mixramp_interpolate(foo, 4.5).count(),
0.05);
free(foo);
foo = strdup(input);
EXPECT_NEAR(0.9,
2018-10-16 19:01:13 +02:00
mixramp_interpolate(foo, 4).count(),
0.05);
free(foo);
foo = strdup(input);
EXPECT_NEAR(1.7,
2018-10-16 19:01:13 +02:00
mixramp_interpolate(foo, 5).count(),
0.05);
free(foo);
}