mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Cleanup unused Beast bits and pieces:
This cleanup does not remove Boost.Beast code, but old-style Beast which is no longer relevant or helpful.
This commit is contained in:
@@ -17,7 +17,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <ripple/beast/utility/Debug.h>
|
||||
|
||||
namespace beast {
|
||||
|
||||
// A simple unit test to determine the diagnostic settings in a build.
|
||||
@@ -43,21 +43,11 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
static int beastForceDebug()
|
||||
{
|
||||
#ifdef BEAST_FORCE_DEBUG
|
||||
return BEAST_FORCE_DEBUG;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void run() override
|
||||
{
|
||||
log <<
|
||||
"_DEBUG = " << envDebug() << '\n' <<
|
||||
"BEAST_DEBUG = " << beastDebug() << '\n' <<
|
||||
"BEAST_FORCE_DEBUG = " << beastForceDebug() << '\n' <<
|
||||
"sizeof(std::size_t) = " << sizeof(std::size_t) << std::endl;
|
||||
pass();
|
||||
}
|
||||
@@ -65,4 +55,4 @@ public:
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(Debug, utility, beast);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/beast/utility/weak_fn.h>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
|
||||
namespace beast {
|
||||
|
||||
class weak_fn_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
struct T
|
||||
{
|
||||
bool& called_;
|
||||
|
||||
explicit
|
||||
T (bool& called)
|
||||
: called_(called)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
fv()
|
||||
{
|
||||
called_ = true;
|
||||
}
|
||||
|
||||
void
|
||||
fi(int i)
|
||||
{
|
||||
called_ = true;
|
||||
}
|
||||
|
||||
void
|
||||
fis(int, std::string)
|
||||
{
|
||||
called_ = true;
|
||||
}
|
||||
|
||||
int
|
||||
fri()
|
||||
{
|
||||
called_ = true;
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
{
|
||||
bool called = false;
|
||||
auto const p = std::make_shared<T>(called);
|
||||
std::bind(weak_fn(&T::fv, p))();
|
||||
BEAST_EXPECT(called);
|
||||
}
|
||||
|
||||
{
|
||||
bool called = false;
|
||||
auto p = std::make_shared<T>(called);
|
||||
auto call = std::bind(weak_fn(&T::fv, p));
|
||||
p.reset();
|
||||
call();
|
||||
BEAST_EXPECT(! called);
|
||||
}
|
||||
|
||||
{
|
||||
bool called = false;
|
||||
auto p = std::make_shared<T>(called);
|
||||
std::bind(weak_fn(&T::fi, p), 1)();
|
||||
BEAST_EXPECT(called);
|
||||
}
|
||||
|
||||
{
|
||||
bool called = false;
|
||||
auto p = std::make_shared<T>(called);
|
||||
std::bind(weak_fn(&T::fi, p),
|
||||
std::placeholders::_1)(1);
|
||||
BEAST_EXPECT(called);
|
||||
}
|
||||
|
||||
{
|
||||
bool called = false;
|
||||
auto p = std::make_shared<T>(called);
|
||||
std::bind(weak_fn(&T::fis, p),
|
||||
1, std::placeholders::_1)("foo");
|
||||
BEAST_EXPECT(called);
|
||||
}
|
||||
|
||||
{
|
||||
bool called = false;
|
||||
auto p = std::make_shared<T>(called);
|
||||
try
|
||||
{
|
||||
auto call = std::bind(weak_fn(&T::fis, p, throw_if_invalid<>()),
|
||||
1, std::placeholders::_1);
|
||||
p.reset();
|
||||
call("foo");
|
||||
fail();
|
||||
}
|
||||
catch(std::bad_weak_ptr const&)
|
||||
{
|
||||
BEAST_EXPECT(! called);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
bool called = false;
|
||||
auto p = std::make_shared<T>(called);
|
||||
BEAST_EXPECT(std::bind(weak_fn(&T::fri, p))() == 2);
|
||||
BEAST_EXPECT(called);
|
||||
}
|
||||
|
||||
{
|
||||
bool called = false;
|
||||
auto p = std::make_shared<T>(called);
|
||||
auto call = std::bind(weak_fn(&T::fv, p,
|
||||
[&called]()
|
||||
{
|
||||
called = true;
|
||||
}));
|
||||
p.reset();
|
||||
call();
|
||||
BEAST_EXPECT(called);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(weak_fn,asio,beast);
|
||||
|
||||
}
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <test/beast/beast_weak_fn_test.cpp>
|
||||
#include <test/beast/beast_Zero_test.cpp>
|
||||
#include <test/beast/define_print.cpp>
|
||||
#include <test/beast/IPEndpoint_test.cpp>
|
||||
|
||||
Reference in New Issue
Block a user