mirror of https://github.com/OpenMW/openmw.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
3 years ago
|
#include "format.hpp"
|
||
|
|
||
3 years ago
|
#include <components/serialization/sizeaccumulator.hpp>
|
||
3 years ago
|
|
||
|
#include <gtest/gtest.h>
|
||
|
|
||
|
#include <cstddef>
|
||
|
#include <cstdint>
|
||
|
#include <variant>
|
||
|
#include <vector>
|
||
|
|
||
|
namespace
|
||
|
{
|
||
|
using namespace testing;
|
||
3 years ago
|
using namespace Serialization;
|
||
|
using namespace SerializationTesting;
|
||
3 years ago
|
|
||
|
TEST(DetourNavigatorSerializationSizeAccumulatorTest, shouldProvideSizeForArithmeticType)
|
||
|
{
|
||
|
SizeAccumulator sizeAccumulator;
|
||
|
constexpr std::monostate format;
|
||
|
sizeAccumulator(format, std::uint32_t());
|
||
|
EXPECT_EQ(sizeAccumulator.value(), 4);
|
||
|
}
|
||
|
|
||
|
TEST(DetourNavigatorSerializationSizeAccumulatorTest, shouldProvideSizeForArithmeticTypeRange)
|
||
|
{
|
||
|
SizeAccumulator sizeAccumulator;
|
||
|
const std::uint64_t* const data = nullptr;
|
||
|
const std::size_t count = 3;
|
||
|
const std::monostate format;
|
||
|
sizeAccumulator(format, data, count);
|
||
|
EXPECT_EQ(sizeAccumulator.value(), 24);
|
||
|
}
|
||
|
|
||
|
TEST(DetourNavigatorSerializationSizeAccumulatorTest, shouldSupportCustomSerializer)
|
||
|
{
|
||
|
SizeAccumulator sizeAccumulator;
|
||
|
const TestFormat<Mode::Write> format;
|
||
2 years ago
|
sizeAccumulator(format, Pod{});
|
||
3 years ago
|
EXPECT_EQ(sizeAccumulator.value(), 12);
|
||
|
}
|
||
|
}
|