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

48 lines
1019 B
C++

#include <gtest/gtest.h>
#include <boost/scoped_ptr.hpp>
#include <algorithm>
#include <vector>
#include <fstream>
#include "image.h"
#include "classifier.h"
#include "bit_string_reader.h"
#include "utils.h"
#include "test_utils.h"
using namespace std;
using namespace Chromaprint;
TEST(BitStringReader, OneByte)
{
char data[] = { -28 };
BitStringReader reader(string(data, 1));
ASSERT_EQ(0, reader.Read(2));
ASSERT_EQ(1, reader.Read(2));
ASSERT_EQ(2, reader.Read(2));
ASSERT_EQ(3, reader.Read(2));
}
TEST(BitStringReader, TwoBytesIncomplete)
{
char data[] = { -28, 1 };
BitStringReader reader(string(data, 2));
ASSERT_EQ(0, reader.Read(2));
ASSERT_EQ(1, reader.Read(2));
ASSERT_EQ(2, reader.Read(2));
ASSERT_EQ(3, reader.Read(2));
ASSERT_EQ(1, reader.Read(2));
}
TEST(BitStringReader, TwoBytesSplit)
{
char data[] = { -120, 6 };
BitStringReader reader(string(data, 2));
ASSERT_EQ(0, reader.Read(3));
ASSERT_EQ(1, reader.Read(3));
ASSERT_EQ(2, reader.Read(3));
ASSERT_EQ(3, reader.Read(3));
}