mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-03 01:15:53 +00:00
Merge branch 'develop' of github.com:ripple/rippled into develop
This commit is contained in:
@@ -242,3 +242,36 @@ void RangeSet::checkInternalConsistency () const noexcept
|
||||
#endif
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class RangeSetTests : public UnitTest
|
||||
{
|
||||
public:
|
||||
RangeSetTests () : UnitTest ("RangeSet", "ripple")
|
||||
{
|
||||
}
|
||||
|
||||
void runTest ()
|
||||
{
|
||||
beginTest ("membership");
|
||||
|
||||
RangeSet r1, r2;
|
||||
|
||||
r1.setRange (1, 10);
|
||||
r1.clearValue (5);
|
||||
r1.setRange (11, 20);
|
||||
|
||||
r2.setRange (1, 4);
|
||||
r2.setRange (6, 10);
|
||||
r2.setRange (10, 20);
|
||||
|
||||
expect (!r1.hasValue (5));
|
||||
|
||||
expect (r2.hasValue (9));
|
||||
|
||||
// TODO: Traverse functions must be tested
|
||||
}
|
||||
};
|
||||
|
||||
static RangeSetTests rangeSetTests;
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (RangeSet_suite)
|
||||
|
||||
BOOST_AUTO_TEST_CASE (RangeSet_test)
|
||||
{
|
||||
using namespace ripple;
|
||||
|
||||
WriteLog (lsTRACE, RangeSet) << "RangeSet test begins";
|
||||
|
||||
RangeSet r1, r2;
|
||||
|
||||
r1.setRange (1, 10);
|
||||
r1.clearValue (5);
|
||||
r1.setRange (11, 20);
|
||||
|
||||
r2.setRange (1, 4);
|
||||
r2.setRange (6, 10);
|
||||
r2.setRange (10, 20);
|
||||
|
||||
if (r1.hasValue (5)) BOOST_FAIL ("RangeSet fail");
|
||||
|
||||
if (!r2.hasValue (9)) BOOST_FAIL ("RangeSet fail");
|
||||
|
||||
// TODO: Traverse functions must be tested
|
||||
|
||||
WriteLog (lsTRACE, RangeSet) << "RangeSet test complete";
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
@@ -27,8 +27,6 @@
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
//#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
// VFALCO TODO Replace OpenSSL randomness with a dependency-free implementation
|
||||
// Perhaps Schneier's Fortuna or a variant. Abstract the collection of
|
||||
// entropy and provide OS-specific implementation. We can re-use the
|
||||
@@ -45,10 +43,6 @@
|
||||
#include <Winsock2.h> // for ripple_ByteOrder.cpp
|
||||
#endif
|
||||
|
||||
// This brings in the definitions for the Unit Test Framework.
|
||||
//
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
namespace ripple
|
||||
{
|
||||
|
||||
@@ -73,7 +67,3 @@ namespace ripple
|
||||
#include "types/ripple_UInt256.cpp"
|
||||
|
||||
}
|
||||
|
||||
// These must be outside the namespace (because of boost)
|
||||
#include "containers/ripple_RangeSetUnitTests.cpp"
|
||||
#include "utility/ripple_StringUtilitiesUnitTests.cpp"
|
||||
|
||||
@@ -25,9 +25,6 @@
|
||||
// This is better than setting it in some Makefile or IDE Project file.
|
||||
//
|
||||
#define BOOST_FILESYSTEM_NO_DEPRECATED
|
||||
#define BOOST_TEST_NO_LIB
|
||||
#define BOOST_TEST_ALTERNATIVE_INIT_API
|
||||
#define BOOST_TEST_NO_MAIN
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
@@ -47,7 +44,6 @@
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/recursive_mutex.hpp>
|
||||
|
||||
@@ -135,8 +135,6 @@ StringPairArray parseKeyValueSection (Section& secSource, String const& strSecti
|
||||
// yuck.
|
||||
std::string const stdStrSection (strSection.toStdString ());
|
||||
|
||||
int const count = SectionCount (secSource, stdStrSection);
|
||||
|
||||
typedef Section::mapped_type Entries;
|
||||
|
||||
Entries* const entries = SectionEntries (secSource, stdStrSection);
|
||||
|
||||
@@ -309,3 +309,61 @@ StringPairArray parseDelimitedKeyValueString (String parameters, beast_wchar del
|
||||
|
||||
return keyValues;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class StringUtilitiesTests : public UnitTest
|
||||
{
|
||||
public:
|
||||
StringUtilitiesTests () : UnitTest ("StringUtilities", "ripple")
|
||||
{
|
||||
}
|
||||
|
||||
void runTest ()
|
||||
{
|
||||
beginTest ("parseUrl");
|
||||
|
||||
std::string strScheme;
|
||||
std::string strDomain;
|
||||
int iPort;
|
||||
std::string strPath;
|
||||
|
||||
if (!parseUrl ("lower://domain", strScheme, strDomain, iPort, strPath))
|
||||
fail ("parseUrl: lower://domain failed");
|
||||
|
||||
if (strScheme != "lower")
|
||||
fail ("parseUrl: lower://domain : scheme failed");
|
||||
|
||||
if (strDomain != "domain")
|
||||
fail ("parseUrl: lower://domain : domain failed");
|
||||
|
||||
if (iPort != -1)
|
||||
fail ("parseUrl: lower://domain : port failed");
|
||||
|
||||
if (strPath != "")
|
||||
fail ("parseUrl: lower://domain : path failed");
|
||||
|
||||
if (!parseUrl ("UPPER://domain:234/", strScheme, strDomain, iPort, strPath))
|
||||
fail ("parseUrl: UPPER://domain:234/ failed");
|
||||
|
||||
if (strScheme != "upper")
|
||||
fail ("parseUrl: UPPER://domain:234/ : scheme failed");
|
||||
|
||||
if (iPort != 234)
|
||||
fail (boost::str (boost::format ("parseUrl: UPPER://domain:234/ : port failed: %d") % iPort));
|
||||
|
||||
if (strPath != "/")
|
||||
fail ("parseUrl: UPPER://domain:234/ : path failed");
|
||||
|
||||
if (!parseUrl ("Mixed://domain/path", strScheme, strDomain, iPort, strPath))
|
||||
fail ("parseUrl: Mixed://domain/path failed");
|
||||
|
||||
if (strScheme != "mixed")
|
||||
fail ("parseUrl: Mixed://domain/path tolower failed");
|
||||
|
||||
if (strPath != "/path")
|
||||
fail ("parseUrl: Mixed://domain/path path failed");
|
||||
}
|
||||
};
|
||||
|
||||
static StringUtilitiesTests stringUtilitiesTests;
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
BOOST_AUTO_TEST_SUITE ( Utils)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( ParseUrl )
|
||||
{
|
||||
using namespace ripple;
|
||||
|
||||
std::string strScheme;
|
||||
std::string strDomain;
|
||||
int iPort;
|
||||
std::string strPath;
|
||||
|
||||
if (!parseUrl ("lower://domain", strScheme, strDomain, iPort, strPath))
|
||||
BOOST_FAIL ("parseUrl: lower://domain failed");
|
||||
|
||||
if (strScheme != "lower")
|
||||
BOOST_FAIL ("parseUrl: lower://domain : scheme failed");
|
||||
|
||||
if (strDomain != "domain")
|
||||
BOOST_FAIL ("parseUrl: lower://domain : domain failed");
|
||||
|
||||
if (iPort != -1)
|
||||
BOOST_FAIL ("parseUrl: lower://domain : port failed");
|
||||
|
||||
if (strPath != "")
|
||||
BOOST_FAIL ("parseUrl: lower://domain : path failed");
|
||||
|
||||
if (!parseUrl ("UPPER://domain:234/", strScheme, strDomain, iPort, strPath))
|
||||
BOOST_FAIL ("parseUrl: UPPER://domain:234/ failed");
|
||||
|
||||
if (strScheme != "upper")
|
||||
BOOST_FAIL ("parseUrl: UPPER://domain:234/ : scheme failed");
|
||||
|
||||
if (iPort != 234)
|
||||
BOOST_FAIL (boost::str (boost::format ("parseUrl: UPPER://domain:234/ : port failed: %d") % iPort));
|
||||
|
||||
if (strPath != "/")
|
||||
BOOST_FAIL ("parseUrl: UPPER://domain:234/ : path failed");
|
||||
|
||||
if (!parseUrl ("Mixed://domain/path", strScheme, strDomain, iPort, strPath))
|
||||
BOOST_FAIL ("parseUrl: Mixed://domain/path failed");
|
||||
|
||||
if (strScheme != "mixed")
|
||||
BOOST_FAIL ("parseUrl: Mixed://domain/path tolower failed");
|
||||
|
||||
if (strPath != "/path")
|
||||
BOOST_FAIL ("parseUrl: Mixed://domain/path path failed");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
Reference in New Issue
Block a user