1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-28 18:18:52 +00:00
OpenMW/apps/components_tests/misc/compression.cpp
elsid 7d1cd11ba9
Split openmw_test_suite into openmw and components tests
To avoid duplicated compilation for openmw translation units. Link openmw-lib to
openmw-tests instead.
2024-06-10 23:12:14 +02:00

32 lines
870 B
C++

#include <components/misc/compression.hpp>
#include <gtest/gtest.h>
#include <algorithm>
#include <cstdlib>
#include <cstring>
namespace
{
using namespace testing;
using namespace Misc;
TEST(MiscCompressionTest, compressShouldAddPrefixWithDataSize)
{
const std::vector<std::byte> data(1234);
const std::vector<std::byte> compressed = compress(data);
int size = 0;
std::memcpy(&size, compressed.data(), sizeof(size));
EXPECT_EQ(size, data.size());
}
TEST(MiscCompressionTest, decompressIsInverseToCompress)
{
const std::vector<std::byte> data(1024);
const std::vector<std::byte> compressed = compress(data);
EXPECT_LT(compressed.size(), data.size());
const std::vector<std::byte> decompressed = decompress(compressed);
EXPECT_EQ(decompressed, data);
}
}