mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-02 12:36:36 +00:00
Update fmt lib, add recast, wip on recast pathfinder interface (broken atm)
This commit is contained in:
@@ -64,7 +64,7 @@ namespace {
|
||||
struct Test {};
|
||||
|
||||
template <typename Char>
|
||||
void format(fmt::BasicFormatter<Char> &f, const Char *, Test) {
|
||||
void format_arg(fmt::BasicFormatter<Char> &f, const Char *, Test) {
|
||||
f.writer() << "test";
|
||||
}
|
||||
|
||||
@@ -83,8 +83,8 @@ void CheckForwarding(
|
||||
// Check if value_type is properly defined.
|
||||
AllocatorRef< MockAllocator<int> >::value_type *ptr = &mem;
|
||||
// Check forwarding.
|
||||
EXPECT_CALL(alloc, allocate(42)).WillOnce(Return(ptr));
|
||||
ref.allocate(42);
|
||||
EXPECT_CALL(alloc, allocate(42, 0)).WillOnce(Return(ptr));
|
||||
ref.allocate(42, 0);
|
||||
EXPECT_CALL(alloc, deallocate(ptr, 42));
|
||||
ref.deallocate(ptr, 42);
|
||||
}
|
||||
@@ -339,7 +339,7 @@ TEST(MemoryBufferTest, Grow) {
|
||||
EXPECT_EQ(10u, buffer.capacity());
|
||||
int mem[20];
|
||||
mem[7] = 0xdead;
|
||||
EXPECT_CALL(alloc, allocate(20)).WillOnce(Return(mem));
|
||||
EXPECT_CALL(alloc, allocate(20, 0)).WillOnce(Return(mem));
|
||||
buffer.grow(20);
|
||||
EXPECT_EQ(20u, buffer.capacity());
|
||||
// Check if size elements have been copied
|
||||
@@ -360,7 +360,7 @@ TEST(MemoryBufferTest, Allocator) {
|
||||
MemoryBuffer<char, 10, TestAllocator> buffer2((TestAllocator(&alloc)));
|
||||
EXPECT_EQ(&alloc, buffer2.get_allocator().get());
|
||||
std::size_t size = 2 * fmt::internal::INLINE_BUFFER_SIZE;
|
||||
EXPECT_CALL(alloc, allocate(size)).WillOnce(Return(&mem));
|
||||
EXPECT_CALL(alloc, allocate(size, 0)).WillOnce(Return(&mem));
|
||||
buffer2.reserve(size);
|
||||
EXPECT_CALL(alloc, deallocate(&mem, size));
|
||||
}
|
||||
@@ -373,13 +373,13 @@ TEST(MemoryBufferTest, ExceptionInDeallocate) {
|
||||
std::size_t size = 2 * fmt::internal::INLINE_BUFFER_SIZE;
|
||||
std::vector<char> mem(size);
|
||||
{
|
||||
EXPECT_CALL(alloc, allocate(size)).WillOnce(Return(&mem[0]));
|
||||
EXPECT_CALL(alloc, allocate(size, 0)).WillOnce(Return(&mem[0]));
|
||||
buffer.resize(size);
|
||||
std::fill(&buffer[0], &buffer[0] + size, 'x');
|
||||
}
|
||||
std::vector<char> mem2(2 * size);
|
||||
{
|
||||
EXPECT_CALL(alloc, allocate(2 * size)).WillOnce(Return(&mem2[0]));
|
||||
EXPECT_CALL(alloc, allocate(2 * size, 0)).WillOnce(Return(&mem2[0]));
|
||||
std::exception e;
|
||||
EXPECT_CALL(alloc, deallocate(&mem[0], size)).WillOnce(testing::Throw(e));
|
||||
EXPECT_THROW(buffer.reserve(2 * size), std::exception);
|
||||
@@ -581,7 +581,7 @@ struct CustomFormatter {
|
||||
typedef char Char;
|
||||
};
|
||||
|
||||
void format(CustomFormatter &, const char *&s, const Test &) {
|
||||
void format_arg(CustomFormatter &, const char *&s, const Test &) {
|
||||
s = "custom_format";
|
||||
}
|
||||
|
||||
@@ -708,7 +708,7 @@ TEST(ArgVisitorTest, VisitUnhandledArg) {
|
||||
|
||||
TEST(ArgVisitorTest, VisitInvalidArg) {
|
||||
Arg arg = Arg();
|
||||
arg.type = static_cast<Arg::Type>(Arg::CUSTOM + 1);
|
||||
arg.type = static_cast<Arg::Type>(Arg::NONE);
|
||||
EXPECT_ASSERT(TestVisitor().visit(arg), "invalid argument type");
|
||||
}
|
||||
|
||||
@@ -834,10 +834,10 @@ void check_throw_error(int error_code, FormatErrorMessage format) {
|
||||
|
||||
TEST(UtilTest, FormatSystemError) {
|
||||
fmt::MemoryWriter message;
|
||||
fmt::internal::format_system_error(message, EDOM, "test");
|
||||
fmt::format_system_error(message, EDOM, "test");
|
||||
EXPECT_EQ(fmt::format("test: {}", get_system_error(EDOM)), message.str());
|
||||
message.clear();
|
||||
fmt::internal::format_system_error(
|
||||
fmt::format_system_error(
|
||||
message, EDOM, fmt::StringRef(0, std::numeric_limits<size_t>::max()));
|
||||
EXPECT_EQ(fmt::format("error {}", EDOM), message.str());
|
||||
}
|
||||
@@ -846,12 +846,12 @@ TEST(UtilTest, SystemError) {
|
||||
fmt::SystemError e(EDOM, "test");
|
||||
EXPECT_EQ(fmt::format("test: {}", get_system_error(EDOM)), e.what());
|
||||
EXPECT_EQ(EDOM, e.error_code());
|
||||
check_throw_error<fmt::SystemError>(EDOM, fmt::internal::format_system_error);
|
||||
check_throw_error<fmt::SystemError>(EDOM, fmt::format_system_error);
|
||||
}
|
||||
|
||||
TEST(UtilTest, ReportSystemError) {
|
||||
fmt::MemoryWriter out;
|
||||
fmt::internal::format_system_error(out, EDOM, "test error");
|
||||
fmt::format_system_error(out, EDOM, "test error");
|
||||
out << '\n';
|
||||
EXPECT_WRITE(stderr, fmt::report_system_error(EDOM, "test error"), out.str());
|
||||
}
|
||||
@@ -956,3 +956,17 @@ TEST(UtilTest, Conditional) {
|
||||
fmt::internal::Conditional<false, int, char>::type *pc = &c;
|
||||
(void)pc;
|
||||
}
|
||||
|
||||
struct TestLConv {
|
||||
char *thousands_sep;
|
||||
};
|
||||
|
||||
struct EmptyLConv {};
|
||||
|
||||
TEST(UtilTest, ThousandsSep) {
|
||||
char foo[] = "foo";
|
||||
TestLConv lc = {foo};
|
||||
EXPECT_EQ("foo", fmt::internal::thousands_sep(&lc).to_string());
|
||||
EmptyLConv empty_lc;
|
||||
EXPECT_EQ("", fmt::internal::thousands_sep(&empty_lc));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user