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_bit_string_writer.cpp
John Maguire f02732e138 Add Chromaprint to 3rdparty.
(cherry picked from commit 1bcbc2ed3e)
2012-01-11 21:09:40 +00:00

54 lines
1.1 KiB
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_writer.h"
#include "utils.h"
#include "test_utils.h"
using namespace std;
using namespace Chromaprint;
TEST(BitStringWriter, OneByte)
{
BitStringWriter writer;
writer.Write(0, 2);
writer.Write(1, 2);
writer.Write(2, 2);
writer.Write(3, 2);
writer.Flush();
char expected[] = { -28 };
CheckString(writer.value(), expected, sizeof(expected)/sizeof(expected[0]));
}
TEST(BitStringWriter, TwoBytesIncomplete)
{
BitStringWriter writer;
writer.Write(0, 2);
writer.Write(1, 2);
writer.Write(2, 2);
writer.Write(3, 2);
writer.Write(1, 2);
writer.Flush();
char expected[] = { -28, 1 };
CheckString(writer.value(), expected, sizeof(expected)/sizeof(expected[0]));
}
TEST(BitStringWriter, TwoBytesSplit)
{
BitStringWriter writer;
writer.Write(0, 3);
writer.Write(1, 3);
writer.Write(2, 3);
writer.Write(3, 3);
writer.Flush();
char expected[] = { -120, 6 };
CheckString(writer.value(), expected, sizeof(expected)/sizeof(expected[0]));
}