mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-07 07:41:54 +01:00
f02732e138
(cherry picked from commit 1bcbc2ed3e
)
48 lines
1019 B
C++
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));
|
|
}
|