1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-21 22:25:39 +01:00
Clementine-audio-player-Mac.../3rdparty/chromaprint/tests/test_chroma_resampler.cpp
John Maguire f02732e138 Add Chromaprint to 3rdparty.
(cherry picked from commit 1bcbc2ed3e)
2012-01-11 21:09:40 +00:00

49 lines
1.6 KiB
C++

#include <gtest/gtest.h>
#include "image.h"
#include "image_builder.h"
#include "chroma_resampler.h"
using namespace std;
using namespace Chromaprint;
TEST(ChromaResampler, Test1) {
Image image(12);
ImageBuilder builder(&image);
ChromaResampler resampler(2, &builder);
double d1[] = { 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
double d2[] = { 1.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
double d3[] = { 2.0, 7.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
std::vector<double> v1(d1, d1 + 12);
std::vector<double> v2(d2, d2 + 12);
std::vector<double> v3(d3, d3 + 12);
resampler.Consume(v1);
resampler.Consume(v2);
resampler.Consume(v3);
ASSERT_EQ(1, image.NumRows());
EXPECT_EQ(0.5, image[0][0]);
EXPECT_EQ(5.5, image[0][1]);
}
TEST(ChromaResampler, Test2) {
Image image(12);
ImageBuilder builder(&image);
ChromaResampler resampler(2, &builder);
double d1[] = { 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
double d2[] = { 1.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
double d3[] = { 2.0, 7.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
double d4[] = { 3.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
std::vector<double> v1(d1, d1 + 12);
std::vector<double> v2(d2, d2 + 12);
std::vector<double> v3(d3, d3 + 12);
std::vector<double> v4(d4, d4 + 12);
resampler.Consume(v1);
resampler.Consume(v2);
resampler.Consume(v3);
resampler.Consume(v4);
ASSERT_EQ(2, image.NumRows());
EXPECT_EQ(0.5, image[0][0]);
EXPECT_EQ(5.5, image[0][1]);
EXPECT_EQ(2.5, image[1][0]);
EXPECT_EQ(7.5, image[1][1]);
}