mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-05 08:48:03 +00:00
Update unit tests for beast, add JUnit XML output option
This commit is contained in:
11
TODO.txt
11
TODO.txt
@@ -5,18 +5,23 @@ RIPPLE TODO
|
|||||||
Vinnie's List: Changes day to day, descending priority
|
Vinnie's List: Changes day to day, descending priority
|
||||||
(Items marked '*' can be handled by others.)
|
(Items marked '*' can be handled by others.)
|
||||||
|
|
||||||
|
- Remove unnecessary beast .mm files
|
||||||
* Make everyone check GitHub Issues every day
|
* Make everyone check GitHub Issues every day
|
||||||
- Finish unit tests and code for Validators
|
- Finish unit tests and code for Validators
|
||||||
- Do something about the throw() reporting weaknesses:
|
- Do something about the throw() reporting weaknesses:
|
||||||
* Make sure all Sconstruct and .pro builds have debug symbols in release
|
* Make sure all Sconstruct and .pro builds have debug symbols in release
|
||||||
* Replace all throw with beast::Throw()
|
* Replace all throw with beast::Throw()
|
||||||
(Only in ripple sources, not in Subtrees/, protobuf, or websocket)
|
(Only in ripple sources, not in Subtrees/, protobuf, or websocket)
|
||||||
|
- Improved Beast exception object, provides __FILE__ and __LINE__
|
||||||
- Add file and line capabilities to beast::Throw()
|
- Add file and line capabilities to beast::Throw()
|
||||||
- Allow beast::Throw to be hooked for logging
|
- Allow beast::Throw to be hooked for logging
|
||||||
- Add stack trace capability to beast::Throw() diagnostics via the hook
|
- Add stack trace capability to beast::Throw() diagnostics via the hook
|
||||||
(use the existing beast::SystemStats::getStackBacktrace())
|
(use the existing beast::SystemStats::getStackBacktrace())
|
||||||
- Implement getStackBacktrace for BEAST_BSD targets
|
- Implement getStackBacktrace for BEAST_BSD targets
|
||||||
- Use the result of the beast UnitTests as the return code for main()
|
- Add UnhandledExceptionCatcher to beast
|
||||||
|
- Return EXIT_FAILURE on unhandled exception
|
||||||
|
- Add "FailingTests" and "PassingTests" to beast, run manually, to
|
||||||
|
help test CI scripts.
|
||||||
* Document the command line options for the beast unit test framework
|
* Document the command line options for the beast unit test framework
|
||||||
- Tidy up all the loose files at the root of the repository
|
- Tidy up all the loose files at the root of the repository
|
||||||
- What the heck is up with site_scons/site_tools/protoc.py?
|
- What the heck is up with site_scons/site_tools/protoc.py?
|
||||||
@@ -27,6 +32,10 @@ Vinnie's List: Changes day to day, descending priority
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
- Get rid of the WriteLog() stuff in the ripple tests and make it report the
|
||||||
|
message directly to the UnitTest object. Then update the JUnit XML output
|
||||||
|
routines to also write the auxiliary messages.
|
||||||
|
|
||||||
* Take away the "I" prefix from abstract interface classes, in both the class
|
* Take away the "I" prefix from abstract interface classes, in both the class
|
||||||
name and the file name. It is messing up sorting in the IDE. Use "Imp" or
|
name and the file name. It is messing up sorting in the IDE. Use "Imp" or
|
||||||
suffix for implementations.
|
suffix for implementations.
|
||||||
|
|||||||
@@ -1926,7 +1926,7 @@ public:
|
|||||||
|
|
||||||
void runTest ()
|
void runTest ()
|
||||||
{
|
{
|
||||||
beginTest ("uint256");
|
beginTestCase ("uint256");
|
||||||
|
|
||||||
uint256 uBig ("D2DC44E5DC189318DB36EF87D2104CDF0A0FE3A4B698BEEE55038D7EA4C68000");
|
uint256 uBig ("D2DC44E5DC189318DB36EF87D2104CDF0A0FE3A4B698BEEE55038D7EA4C68000");
|
||||||
|
|
||||||
|
|||||||
@@ -125,12 +125,13 @@ void printHelp (const po::options_description& desc)
|
|||||||
class RippleUnitTests : public UnitTests
|
class RippleUnitTests : public UnitTests
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RippleUnitTests ()
|
explicit RippleUnitTests (bool shouldLog)
|
||||||
|
: m_shouldLog (shouldLog)
|
||||||
{
|
{
|
||||||
// VFALCO NOTE It sucks that we have to do this but some
|
// VFALCO NOTE It sucks that we have to do this but some
|
||||||
// code demands the Application object exists.
|
// code demands the Application object exists.
|
||||||
//
|
//
|
||||||
// To find out who, just change the 1 to 0
|
// TODO To find out who, just change the #if 1 to #if 0
|
||||||
#if 1
|
#if 1
|
||||||
setupConfigForUnitTests (&getConfig ());
|
setupConfigForUnitTests (&getConfig ());
|
||||||
|
|
||||||
@@ -138,12 +139,12 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
setAssertOnFailure (false);
|
setAssertOnFailure (false);
|
||||||
setPassesAreLogged (false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void logMessage (String const& message)
|
void logMessage (String const& message)
|
||||||
{
|
{
|
||||||
Log::out () << message.toStdString ();
|
if (m_shouldLog)
|
||||||
|
Log::out () << message.toStdString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -153,8 +154,48 @@ private:
|
|||||||
config->ephemeralNodeDatabase = StringPairArray ();
|
config->ephemeralNodeDatabase = StringPairArray ();
|
||||||
config->importNodeDatabase = StringPairArray ();
|
config->importNodeDatabase = StringPairArray ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool const m_shouldLog;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int runUnitTests (String const& whichTests, String const& format)
|
||||||
|
{
|
||||||
|
bool const shouldLog = format != "junit";
|
||||||
|
|
||||||
|
if (format != "junit" && format != "text" && format != "")
|
||||||
|
{
|
||||||
|
String s;
|
||||||
|
s << "Warning, unknown unittest-format='" << format << "'";
|
||||||
|
Log::out () << s.toStdString ();
|
||||||
|
}
|
||||||
|
|
||||||
|
RippleUnitTests tr (shouldLog);
|
||||||
|
|
||||||
|
if (whichTests == "")
|
||||||
|
{
|
||||||
|
tr.runAllTests ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tr.runTestsByName (whichTests);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format == "junit")
|
||||||
|
{
|
||||||
|
UnitTestUtilities::JUnitXMLFormatter f (tr);
|
||||||
|
|
||||||
|
String const s = f.createDocumentString ();
|
||||||
|
|
||||||
|
Log::out () << s.toStdString ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return tr.anyTestsFailed () ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
int rippleMain (int argc, char** argv)
|
int rippleMain (int argc, char** argv)
|
||||||
@@ -219,6 +260,7 @@ int rippleMain (int argc, char** argv)
|
|||||||
("standalone,a", "Run with no peers.")
|
("standalone,a", "Run with no peers.")
|
||||||
("testnet,t", "Run in test net mode.")
|
("testnet,t", "Run in test net mode.")
|
||||||
("unittest,u", po::value <std::string> ()->implicit_value (""), "Perform unit tests.")
|
("unittest,u", po::value <std::string> ()->implicit_value (""), "Perform unit tests.")
|
||||||
|
("unittest-format", po::value <std::string> ()->implicit_value ("text"), "Format unit test output. Choices are 'text', 'junit'")
|
||||||
("parameters", po::value< vector<string> > (), "Specify comma separated parameters.")
|
("parameters", po::value< vector<string> > (), "Specify comma separated parameters.")
|
||||||
("quiet,q", "Reduce diagnotics.")
|
("quiet,q", "Reduce diagnotics.")
|
||||||
("verbose,v", "Verbose logging.")
|
("verbose,v", "Verbose logging.")
|
||||||
@@ -318,22 +360,12 @@ int rippleMain (int argc, char** argv)
|
|||||||
//
|
//
|
||||||
if (vm.count ("unittest"))
|
if (vm.count ("unittest"))
|
||||||
{
|
{
|
||||||
String const arg = vm ["unittest"].as <std::string> ();
|
String format;
|
||||||
|
|
||||||
RippleUnitTests tr;
|
if (vm.count ("unittest-format"))
|
||||||
|
format = vm ["unittest-format"].as <std::string> ();
|
||||||
|
|
||||||
if (arg == "")
|
return runUnitTests (vm ["unittest"].as <std::string> (), format);
|
||||||
{
|
|
||||||
tr.runAllTests ();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tr.runTest (arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
iResult = tr.anyTestsFailed () ? EXIT_FAILURE : EXIT_SUCCESS;
|
|
||||||
|
|
||||||
return iResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!iResult)
|
if (!iResult)
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ public:
|
|||||||
String s;
|
String s;
|
||||||
|
|
||||||
s << "solve difficulty " << String (pow.getDifficulty ());
|
s << "solve difficulty " << String (pow.getDifficulty ());
|
||||||
beginTest ("solve");
|
beginTestCase ("solve");
|
||||||
|
|
||||||
uint256 solution = pow.solve (16777216);
|
uint256 solution = pow.solve (16777216);
|
||||||
|
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ public:
|
|||||||
|
|
||||||
void runTest ()
|
void runTest ()
|
||||||
{
|
{
|
||||||
beginTest ("tx");
|
beginTestCase ("tx");
|
||||||
|
|
||||||
RippleAddress seed;
|
RippleAddress seed;
|
||||||
seed.setSeedRandom ();
|
seed.setSeedRandom ();
|
||||||
@@ -313,7 +313,7 @@ public:
|
|||||||
j.setFieldVL (sfMessageKey, publicAcct.getAccountPublic ());
|
j.setFieldVL (sfMessageKey, publicAcct.getAccountPublic ());
|
||||||
j.sign (privateAcct);
|
j.sign (privateAcct);
|
||||||
|
|
||||||
if (!j.checkSign ()) fail ("Transaction fails signature test");
|
unexpected (!j.checkSign (), "Transaction fails signature test");
|
||||||
|
|
||||||
Serializer rawTxn;
|
Serializer rawTxn;
|
||||||
j.add (rawTxn);
|
j.add (rawTxn);
|
||||||
@@ -326,6 +326,10 @@ public:
|
|||||||
Log (lsFATAL) << copy.getJson (0);
|
Log (lsFATAL) << copy.getJson (0);
|
||||||
fail ("Transaction fails serialize/deserialize test");
|
fail ("Transaction fails serialize/deserialize test");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pass ();
|
||||||
|
}
|
||||||
|
|
||||||
UPTR_T<STObject> new_obj = STObject::parseJson (j.getJson (0), sfGeneric);
|
UPTR_T<STObject> new_obj = STObject::parseJson (j.getJson (0), sfGeneric);
|
||||||
|
|
||||||
@@ -337,6 +341,10 @@ public:
|
|||||||
Log (lsINFO) << "BUILT " << new_obj->getJson (0);
|
Log (lsINFO) << "BUILT " << new_obj->getJson (0);
|
||||||
fail ("Built a different transaction");
|
fail ("Built a different transaction");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pass ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -729,7 +729,7 @@ public:
|
|||||||
// Make sure predictable object generation works!
|
// Make sure predictable object generation works!
|
||||||
void testBatches (int64 const seedValue)
|
void testBatches (int64 const seedValue)
|
||||||
{
|
{
|
||||||
beginTest ("batch");
|
beginTestCase ("batch");
|
||||||
|
|
||||||
Batch batch1;
|
Batch batch1;
|
||||||
createPredictableBatch (batch1, 0, numObjectsToTest, seedValue);
|
createPredictableBatch (batch1, 0, numObjectsToTest, seedValue);
|
||||||
@@ -748,7 +748,7 @@ public:
|
|||||||
// Checks encoding/decoding blobs
|
// Checks encoding/decoding blobs
|
||||||
void testBlobs (int64 const seedValue)
|
void testBlobs (int64 const seedValue)
|
||||||
{
|
{
|
||||||
beginTest ("encoding");
|
beginTestCase ("encoding");
|
||||||
|
|
||||||
Batch batch;
|
Batch batch;
|
||||||
createPredictableBatch (batch, 0, numObjectsToTest, seedValue);
|
createPredictableBatch (batch, 0, numObjectsToTest, seedValue);
|
||||||
@@ -798,7 +798,7 @@ public:
|
|||||||
|
|
||||||
void testBackend (String type, int64 const seedValue)
|
void testBackend (String type, int64 const seedValue)
|
||||||
{
|
{
|
||||||
beginTest (String ("NodeStore::Backend type=") + type);
|
beginTestCase (String ("NodeStore::Backend type=") + type);
|
||||||
|
|
||||||
StringPairArray params;
|
StringPairArray params;
|
||||||
File const path (File::createTempFile ("node_db"));
|
File const path (File::createTempFile ("node_db"));
|
||||||
@@ -914,7 +914,7 @@ public:
|
|||||||
{
|
{
|
||||||
String s;
|
String s;
|
||||||
s << "Testing backend '" << type << "' performance";
|
s << "Testing backend '" << type << "' performance";
|
||||||
beginTest (s);
|
beginTestCase (s);
|
||||||
|
|
||||||
StringPairArray params;
|
StringPairArray params;
|
||||||
File const path (File::createTempFile ("node_db"));
|
File const path (File::createTempFile ("node_db"));
|
||||||
@@ -1021,7 +1021,7 @@ public:
|
|||||||
|
|
||||||
ScopedPointer <NodeStore> dest (NodeStore::New (destParams));
|
ScopedPointer <NodeStore> dest (NodeStore::New (destParams));
|
||||||
|
|
||||||
beginTest (String ("import into '") + destBackendType + "' from '" + srcBackendType + "'");
|
beginTestCase (String ("import into '") + destBackendType + "' from '" + srcBackendType + "'");
|
||||||
|
|
||||||
// Do the import
|
// Do the import
|
||||||
dest->import (*src);
|
dest->import (*src);
|
||||||
@@ -1049,7 +1049,7 @@ public:
|
|||||||
if (useEphemeralDatabase)
|
if (useEphemeralDatabase)
|
||||||
s << " (with ephemeral database)";
|
s << " (with ephemeral database)";
|
||||||
|
|
||||||
beginTest (s);
|
beginTestCase (s);
|
||||||
|
|
||||||
File const node_db (File::createTempFile ("node_db"));
|
File const node_db (File::createTempFile ("node_db"));
|
||||||
StringPairArray nodeParams;
|
StringPairArray nodeParams;
|
||||||
|
|||||||
@@ -1074,7 +1074,7 @@ public:
|
|||||||
|
|
||||||
void runTest ()
|
void runTest ()
|
||||||
{
|
{
|
||||||
beginTest ("add/traverse");
|
beginTestCase ("add/traverse");
|
||||||
|
|
||||||
// h3 and h4 differ only in the leaf, same terminal node (level 19)
|
// h3 and h4 differ only in the leaf, same terminal node (level 19)
|
||||||
uint256 h1, h2, h3, h4, h5;
|
uint256 h1, h2, h3, h4, h5;
|
||||||
@@ -1087,23 +1087,23 @@ public:
|
|||||||
SHAMap sMap (smtFREE);
|
SHAMap sMap (smtFREE);
|
||||||
SHAMapItem i1 (h1, IntToVUC (1)), i2 (h2, IntToVUC (2)), i3 (h3, IntToVUC (3)), i4 (h4, IntToVUC (4)), i5 (h5, IntToVUC (5));
|
SHAMapItem i1 (h1, IntToVUC (1)), i2 (h2, IntToVUC (2)), i3 (h3, IntToVUC (3)), i4 (h4, IntToVUC (4)), i5 (h5, IntToVUC (5));
|
||||||
|
|
||||||
if (!sMap.addItem (i2, true, false)) fail ("no add");
|
unexpected (!sMap.addItem (i2, true, false), "no add");
|
||||||
|
|
||||||
if (!sMap.addItem (i1, true, false)) fail ("no add");
|
unexpected (!sMap.addItem (i1, true, false), "no add");
|
||||||
|
|
||||||
SHAMapItem::pointer i;
|
SHAMapItem::pointer i;
|
||||||
|
|
||||||
i = sMap.peekFirstItem ();
|
i = sMap.peekFirstItem ();
|
||||||
|
|
||||||
if (!i || (*i != i1)) fail ("bad traverse");
|
unexpected (!i || (*i != i1), "bad traverse");
|
||||||
|
|
||||||
i = sMap.peekNextItem (i->getTag ());
|
i = sMap.peekNextItem (i->getTag ());
|
||||||
|
|
||||||
if (!i || (*i != i2)) fail ("bad traverse");
|
unexpected (!i || (*i != i2), "bad traverse");
|
||||||
|
|
||||||
i = sMap.peekNextItem (i->getTag ());
|
i = sMap.peekNextItem (i->getTag ());
|
||||||
|
|
||||||
if (i) fail ("bad traverse");
|
unexpected (i, "bad traverse");
|
||||||
|
|
||||||
sMap.addItem (i4, true, false);
|
sMap.addItem (i4, true, false);
|
||||||
sMap.delItem (i2.getTag ());
|
sMap.delItem (i2.getTag ());
|
||||||
@@ -1111,36 +1111,36 @@ public:
|
|||||||
|
|
||||||
i = sMap.peekFirstItem ();
|
i = sMap.peekFirstItem ();
|
||||||
|
|
||||||
if (!i || (*i != i1)) fail ("bad traverse");
|
unexpected (!i || (*i != i1), "bad traverse");
|
||||||
|
|
||||||
i = sMap.peekNextItem (i->getTag ());
|
i = sMap.peekNextItem (i->getTag ());
|
||||||
|
|
||||||
if (!i || (*i != i3)) fail ("bad traverse");
|
unexpected (!i || (*i != i3), "bad traverse");
|
||||||
|
|
||||||
i = sMap.peekNextItem (i->getTag ());
|
i = sMap.peekNextItem (i->getTag ());
|
||||||
|
|
||||||
if (!i || (*i != i4)) fail ("bad traverse");
|
unexpected (!i || (*i != i4), "bad traverse");
|
||||||
|
|
||||||
i = sMap.peekNextItem (i->getTag ());
|
i = sMap.peekNextItem (i->getTag ());
|
||||||
|
|
||||||
if (i) fail ("bad traverse");
|
unexpected (i, "bad traverse");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
beginTest ("snapshot");
|
beginTestCase ("snapshot");
|
||||||
|
|
||||||
uint256 mapHash = sMap.getHash ();
|
uint256 mapHash = sMap.getHash ();
|
||||||
SHAMap::pointer map2 = sMap.snapShot (false);
|
SHAMap::pointer map2 = sMap.snapShot (false);
|
||||||
|
|
||||||
if (sMap.getHash () != mapHash) fail ("bad snapshot");
|
unexpected (sMap.getHash () != mapHash, "bad snapshot");
|
||||||
|
|
||||||
if (map2->getHash () != mapHash) fail ("bad snapshot");
|
unexpected (map2->getHash () != mapHash, "bad snapshot");
|
||||||
|
|
||||||
if (!sMap.delItem (sMap.peekFirstItem ()->getTag ())) fail ("bad mod");
|
unexpected (!sMap.delItem (sMap.peekFirstItem ()->getTag ()), "bad mod");
|
||||||
|
|
||||||
if (sMap.getHash () == mapHash) fail ("bad snapshot");
|
unexpected (sMap.getHash () == mapHash, "bad snapshot");
|
||||||
|
|
||||||
if (map2->getHash () != mapHash) fail ("bad snapshot");
|
unexpected (map2->getHash () != mapHash, "bad snapshot");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -653,7 +653,6 @@ public:
|
|||||||
|
|
||||||
void runTest ()
|
void runTest ()
|
||||||
{
|
{
|
||||||
beginTest ("sync");
|
|
||||||
unsigned int seed;
|
unsigned int seed;
|
||||||
|
|
||||||
// VFALCO TODO Replace this with beast::Random
|
// VFALCO TODO Replace this with beast::Random
|
||||||
@@ -668,9 +667,9 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
beginTest ("add/remove");
|
beginTestCase ("add/remove");
|
||||||
|
|
||||||
if (!confuseMap (source, 500)) fail ("ConfuseMap");
|
unexpected (!confuseMap (source, 500), "ConfuseMap");
|
||||||
|
|
||||||
source.setImmutable ();
|
source.setImmutable ();
|
||||||
|
|
||||||
@@ -686,20 +685,12 @@ public:
|
|||||||
|
|
||||||
destination.setSynching ();
|
destination.setSynching ();
|
||||||
|
|
||||||
if (!source.getNodeFat (SHAMapNode (), nodeIDs, gotNodes, (rand () % 2) == 0, (rand () % 2) == 0))
|
unexpected (!source.getNodeFat (SHAMapNode (), nodeIDs, gotNodes, (rand () % 2) == 0, (rand () % 2) == 0),
|
||||||
{
|
"GetNodeFat");
|
||||||
fail ("GetNodeFat");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gotNodes.size () < 1)
|
unexpected (gotNodes.size () < 1, "NodeSize");
|
||||||
{
|
|
||||||
fail ("NodeSize");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!destination.addRootNode (*gotNodes.begin (), snfWIRE, NULL))
|
unexpected (!destination.addRootNode (*gotNodes.begin (), snfWIRE, NULL), "AddRootNode");
|
||||||
{
|
|
||||||
fail ("AddRootNode");
|
|
||||||
}
|
|
||||||
|
|
||||||
nodeIDs.clear ();
|
nodeIDs.clear ();
|
||||||
gotNodes.clear ();
|
gotNodes.clear ();
|
||||||
@@ -726,6 +717,10 @@ public:
|
|||||||
WriteLog (lsFATAL, SHAMap) << "GetNodeFat fails";
|
WriteLog (lsFATAL, SHAMap) << "GetNodeFat fails";
|
||||||
fail ("GetNodeFat");
|
fail ("GetNodeFat");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pass ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (gotNodeIDs.size () == gotNodes.size ());
|
assert (gotNodeIDs.size () == gotNodes.size ());
|
||||||
@@ -736,6 +731,10 @@ public:
|
|||||||
{
|
{
|
||||||
fail ("Got Node ID");
|
fail ("Got Node ID");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pass ();
|
||||||
|
}
|
||||||
|
|
||||||
for (nodeIDIterator = gotNodeIDs.begin (), rawNodeIterator = gotNodes.begin ();
|
for (nodeIDIterator = gotNodeIDs.begin (), rawNodeIterator = gotNodes.begin ();
|
||||||
nodeIDIterator != gotNodeIDs.end (); ++nodeIDIterator, ++rawNodeIterator)
|
nodeIDIterator != gotNodeIDs.end (); ++nodeIDIterator, ++rawNodeIterator)
|
||||||
@@ -750,6 +749,10 @@ public:
|
|||||||
WriteLog (lsTRACE, SHAMap) << "AddKnownNode fails";
|
WriteLog (lsTRACE, SHAMap) << "AddKnownNode fails";
|
||||||
fail ("AddKnownNode");
|
fail ("AddKnownNode");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pass ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gotNodeIDs.clear ();
|
gotNodeIDs.clear ();
|
||||||
@@ -768,6 +771,10 @@ public:
|
|||||||
{
|
{
|
||||||
fail ("Deep Compare");
|
fail ("Deep Compare");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pass ();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef SMS_DEBUG
|
#ifdef SMS_DEBUG
|
||||||
WriteLog (lsINFO, SHAMap) << "SHAMapSync test passed: " << items << " items, " <<
|
WriteLog (lsINFO, SHAMap) << "SHAMapSync test passed: " << items << " items, " <<
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ public:
|
|||||||
|
|
||||||
void testMembership ()
|
void testMembership ()
|
||||||
{
|
{
|
||||||
beginTest ("membership");
|
beginTestCase ("membership");
|
||||||
|
|
||||||
RangeSet r1, r2;
|
RangeSet r1, r2;
|
||||||
|
|
||||||
@@ -288,7 +288,7 @@ public:
|
|||||||
|
|
||||||
void testPrevMissing ()
|
void testPrevMissing ()
|
||||||
{
|
{
|
||||||
beginTest ("prevMissing");
|
beginTestCase ("prevMissing");
|
||||||
|
|
||||||
RangeSet const set = createPredefinedSet ();
|
RangeSet const set = createPredefinedSet ();
|
||||||
|
|
||||||
|
|||||||
@@ -321,48 +321,48 @@ public:
|
|||||||
|
|
||||||
void runTest ()
|
void runTest ()
|
||||||
{
|
{
|
||||||
beginTest ("parseUrl");
|
beginTestCase ("parseUrl");
|
||||||
|
|
||||||
std::string strScheme;
|
std::string strScheme;
|
||||||
std::string strDomain;
|
std::string strDomain;
|
||||||
int iPort;
|
int iPort;
|
||||||
std::string strPath;
|
std::string strPath;
|
||||||
|
|
||||||
if (!parseUrl ("lower://domain", strScheme, strDomain, iPort, strPath))
|
unexpected (!parseUrl ("lower://domain", strScheme, strDomain, iPort, strPath),
|
||||||
fail ("parseUrl: lower://domain failed");
|
"parseUrl: lower://domain failed");
|
||||||
|
|
||||||
if (strScheme != "lower")
|
unexpected (strScheme != "lower",
|
||||||
fail ("parseUrl: lower://domain : scheme failed");
|
"parseUrl: lower://domain : scheme failed");
|
||||||
|
|
||||||
if (strDomain != "domain")
|
unexpected (strDomain != "domain",
|
||||||
fail ("parseUrl: lower://domain : domain failed");
|
"parseUrl: lower://domain : domain failed");
|
||||||
|
|
||||||
if (iPort != -1)
|
unexpected (iPort != -1,
|
||||||
fail ("parseUrl: lower://domain : port failed");
|
"parseUrl: lower://domain : port failed");
|
||||||
|
|
||||||
if (strPath != "")
|
unexpected (strPath != "",
|
||||||
fail ("parseUrl: lower://domain : path failed");
|
"parseUrl: lower://domain : path failed");
|
||||||
|
|
||||||
if (!parseUrl ("UPPER://domain:234/", strScheme, strDomain, iPort, strPath))
|
unexpected (!parseUrl ("UPPER://domain:234/", strScheme, strDomain, iPort, strPath),
|
||||||
fail ("parseUrl: UPPER://domain:234/ failed");
|
"parseUrl: UPPER://domain:234/ failed");
|
||||||
|
|
||||||
if (strScheme != "upper")
|
unexpected (strScheme != "upper",
|
||||||
fail ("parseUrl: UPPER://domain:234/ : scheme failed");
|
"parseUrl: UPPER://domain:234/ : scheme failed");
|
||||||
|
|
||||||
if (iPort != 234)
|
unexpected (iPort != 234,
|
||||||
fail (boost::str (boost::format ("parseUrl: UPPER://domain:234/ : port failed: %d") % iPort));
|
boost::str (boost::format ("parseUrl: UPPER://domain:234/ : port failed: %d") % iPort));
|
||||||
|
|
||||||
if (strPath != "/")
|
unexpected (strPath != "/",
|
||||||
fail ("parseUrl: UPPER://domain:234/ : path failed");
|
"parseUrl: UPPER://domain:234/ : path failed");
|
||||||
|
|
||||||
if (!parseUrl ("Mixed://domain/path", strScheme, strDomain, iPort, strPath))
|
unexpected (!parseUrl ("Mixed://domain/path", strScheme, strDomain, iPort, strPath),
|
||||||
fail ("parseUrl: Mixed://domain/path failed");
|
"parseUrl: Mixed://domain/path failed");
|
||||||
|
|
||||||
if (strScheme != "mixed")
|
unexpected (strScheme != "mixed",
|
||||||
fail ("parseUrl: Mixed://domain/path tolower failed");
|
"parseUrl: Mixed://domain/path tolower failed");
|
||||||
|
|
||||||
if (strPath != "/path")
|
unexpected (strPath != "/path",
|
||||||
fail ("parseUrl: Mixed://domain/path path failed");
|
"parseUrl: Mixed://domain/path path failed");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ public:
|
|||||||
Config d; // get a default configuration object
|
Config d; // get a default configuration object
|
||||||
LoadFeeTrack l;
|
LoadFeeTrack l;
|
||||||
|
|
||||||
|
beginTestCase ("fee scaling");
|
||||||
|
|
||||||
expect (l.scaleFeeBase (10000, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE) == 10000);
|
expect (l.scaleFeeBase (10000, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE) == 10000);
|
||||||
expect (l.scaleFeeLoad (10000, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE, false) == 10000);
|
expect (l.scaleFeeLoad (10000, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE, false) == 10000);
|
||||||
expect (l.scaleFeeBase (1, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE) == 1);
|
expect (l.scaleFeeBase (1, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE) == 1);
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ public:
|
|||||||
// Check logic for comparing a source's fetch results
|
// Check logic for comparing a source's fetch results
|
||||||
void processTest ()
|
void processTest ()
|
||||||
{
|
{
|
||||||
beginTest ("process");
|
beginTestCase ("process");
|
||||||
|
|
||||||
{
|
{
|
||||||
Array <Validator::Info> results = TestSource (1, 32).fetch ();
|
Array <Validator::Info> results = TestSource (1, 32).fetch ();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public:
|
|||||||
|
|
||||||
void runTest ()
|
void runTest ()
|
||||||
{
|
{
|
||||||
beginTest ("determinism");
|
beginTestCase ("determinism");
|
||||||
|
|
||||||
uint128 seed1, seed2;
|
uint128 seed1, seed2;
|
||||||
seed1.SetHex ("71ED064155FFADFA38782C5E0158CB26");
|
seed1.SetHex ("71ED064155FFADFA38782C5E0158CB26");
|
||||||
@@ -32,20 +32,20 @@ public:
|
|||||||
root1.GetPrivateKeyU (priv1);
|
root1.GetPrivateKeyU (priv1);
|
||||||
root2.GetPrivateKeyU (priv2);
|
root2.GetPrivateKeyU (priv2);
|
||||||
|
|
||||||
if (priv1.GetHex () != "7CFBA64F771E93E817E15039215430B53F7401C34931D111EAB3510B22DBB0D8")
|
unexpected (priv1.GetHex () != "7CFBA64F771E93E817E15039215430B53F7401C34931D111EAB3510B22DBB0D8",
|
||||||
fail ("Incorrect private key for generator");
|
"Incorrect private key for generator");
|
||||||
|
|
||||||
if (priv2.GetHex () != "98BC2EACB26EB021D1A6293C044D88BA2F0B6729A2772DEEBF2E21A263C1740B")
|
unexpected (priv2.GetHex () != "98BC2EACB26EB021D1A6293C044D88BA2F0B6729A2772DEEBF2E21A263C1740B",
|
||||||
fail ("Incorrect private key for generator");
|
"Incorrect private key for generator");
|
||||||
|
|
||||||
RippleAddress nSeed;
|
RippleAddress nSeed;
|
||||||
nSeed.setSeed (seed1);
|
nSeed.setSeed (seed1);
|
||||||
|
|
||||||
if (nSeed.humanSeed () != "shHM53KPZ87Gwdqarm1bAmPeXg8Tn")
|
unexpected (nSeed.humanSeed () != "shHM53KPZ87Gwdqarm1bAmPeXg8Tn",
|
||||||
fail ("Incorrect human seed");
|
"Incorrect human seed");
|
||||||
|
|
||||||
if (nSeed.humanSeed1751 () != "MAD BODY ACE MINT OKAY HUB WHAT DATA SACK FLAT DANA MATH")
|
unexpected (nSeed.humanSeed1751 () != "MAD BODY ACE MINT OKAY HUB WHAT DATA SACK FLAT DANA MATH",
|
||||||
fail ("Incorrect 1751 seed");
|
"Incorrect 1751 seed");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -877,7 +877,7 @@ public:
|
|||||||
|
|
||||||
void runTest ()
|
void runTest ()
|
||||||
{
|
{
|
||||||
beginTest ("public/private");
|
beginTestCase ("public/private");
|
||||||
|
|
||||||
// Construct a seed.
|
// Construct a seed.
|
||||||
RippleAddress naSeed;
|
RippleAddress naSeed;
|
||||||
|
|||||||
@@ -1351,6 +1351,10 @@ public:
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pass ();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1372,6 +1376,10 @@ public:
|
|||||||
|
|
||||||
fail ("Multiplication result is not exact");
|
fail ("Multiplication result is not exact");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pass ();
|
||||||
|
}
|
||||||
|
|
||||||
aa = a;
|
aa = a;
|
||||||
prod1 = STAmount::multiply (aa, bb, CURRENCY_ONE, ACCOUNT_ONE);
|
prod1 = STAmount::multiply (aa, bb, CURRENCY_ONE, ACCOUNT_ONE);
|
||||||
@@ -1382,14 +1390,17 @@ public:
|
|||||||
<< " not " << prod2.getFullText ();
|
<< " not " << prod2.getFullText ();
|
||||||
fail ("Multiplication result is not exact");
|
fail ("Multiplication result is not exact");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pass ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
void testSetValue ()
|
void testSetValue ()
|
||||||
{
|
{
|
||||||
beginTest ("set value");
|
beginTestCase ("set value");
|
||||||
|
|
||||||
STAmount saTmp;
|
STAmount saTmp;
|
||||||
|
|
||||||
@@ -1414,296 +1425,296 @@ public:
|
|||||||
|
|
||||||
void testNativeCurrency ()
|
void testNativeCurrency ()
|
||||||
{
|
{
|
||||||
beginTest ("native currency");
|
beginTestCase ("native currency");
|
||||||
|
|
||||||
STAmount zero, one (1), hundred (100);
|
STAmount zero, one (1), hundred (100);
|
||||||
|
|
||||||
if (serializeAndDeserialize (zero) != zero) fail ("STAmount fail");
|
unexpected (serializeAndDeserialize (zero) != zero, "STAmount fail");
|
||||||
|
|
||||||
if (serializeAndDeserialize (one) != one) fail ("STAmount fail");
|
unexpected (serializeAndDeserialize (one) != one, "STAmount fail");
|
||||||
|
|
||||||
if (serializeAndDeserialize (hundred) != hundred) fail ("STAmount fail");
|
unexpected (serializeAndDeserialize (hundred) != hundred, "STAmount fail");
|
||||||
|
|
||||||
if (!zero.isNative ()) fail ("STAmount fail");
|
unexpected (!zero.isNative (), "STAmount fail");
|
||||||
|
|
||||||
if (!hundred.isNative ()) fail ("STAmount fail");
|
unexpected (!hundred.isNative (), "STAmount fail");
|
||||||
|
|
||||||
if (!zero.isZero ()) fail ("STAmount fail");
|
unexpected (!zero.isZero (), "STAmount fail");
|
||||||
|
|
||||||
if (one.isZero ()) fail ("STAmount fail");
|
unexpected (one.isZero (), "STAmount fail");
|
||||||
|
|
||||||
if (hundred.isZero ()) fail ("STAmount fail");
|
unexpected (hundred.isZero (), "STAmount fail");
|
||||||
|
|
||||||
if ((zero < zero)) fail ("STAmount fail");
|
unexpected ((zero < zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero < one)) fail ("STAmount fail");
|
unexpected (! (zero < one), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero < hundred)) fail ("STAmount fail");
|
unexpected (! (zero < hundred), "STAmount fail");
|
||||||
|
|
||||||
if ((one < zero)) fail ("STAmount fail");
|
unexpected ((one < zero), "STAmount fail");
|
||||||
|
|
||||||
if ((one < one)) fail ("STAmount fail");
|
unexpected ((one < one), "STAmount fail");
|
||||||
|
|
||||||
if (! (one < hundred)) fail ("STAmount fail");
|
unexpected (! (one < hundred), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred < zero)) fail ("STAmount fail");
|
unexpected ((hundred < zero), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred < one)) fail ("STAmount fail");
|
unexpected ((hundred < one), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred < hundred)) fail ("STAmount fail");
|
unexpected ((hundred < hundred), "STAmount fail");
|
||||||
|
|
||||||
if ((zero > zero)) fail ("STAmount fail");
|
unexpected ((zero > zero), "STAmount fail");
|
||||||
|
|
||||||
if ((zero > one)) fail ("STAmount fail");
|
unexpected ((zero > one), "STAmount fail");
|
||||||
|
|
||||||
if ((zero > hundred)) fail ("STAmount fail");
|
unexpected ((zero > hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (one > zero)) fail ("STAmount fail");
|
unexpected (! (one > zero), "STAmount fail");
|
||||||
|
|
||||||
if ((one > one)) fail ("STAmount fail");
|
unexpected ((one > one), "STAmount fail");
|
||||||
|
|
||||||
if ((one > hundred)) fail ("STAmount fail");
|
unexpected ((one > hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred > zero)) fail ("STAmount fail");
|
unexpected (! (hundred > zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred > one)) fail ("STAmount fail");
|
unexpected (! (hundred > one), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred > hundred)) fail ("STAmount fail");
|
unexpected ((hundred > hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero <= zero)) fail ("STAmount fail");
|
unexpected (! (zero <= zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero <= one)) fail ("STAmount fail");
|
unexpected (! (zero <= one), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero <= hundred)) fail ("STAmount fail");
|
unexpected (! (zero <= hundred), "STAmount fail");
|
||||||
|
|
||||||
if ((one <= zero)) fail ("STAmount fail");
|
unexpected ((one <= zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (one <= one)) fail ("STAmount fail");
|
unexpected (! (one <= one), "STAmount fail");
|
||||||
|
|
||||||
if (! (one <= hundred)) fail ("STAmount fail");
|
unexpected (! (one <= hundred), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred <= zero)) fail ("STAmount fail");
|
unexpected ((hundred <= zero), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred <= one)) fail ("STAmount fail");
|
unexpected ((hundred <= one), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred <= hundred)) fail ("STAmount fail");
|
unexpected (! (hundred <= hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero >= zero)) fail ("STAmount fail");
|
unexpected (! (zero >= zero), "STAmount fail");
|
||||||
|
|
||||||
if ((zero >= one)) fail ("STAmount fail");
|
unexpected ((zero >= one), "STAmount fail");
|
||||||
|
|
||||||
if ((zero >= hundred)) fail ("STAmount fail");
|
unexpected ((zero >= hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (one >= zero)) fail ("STAmount fail");
|
unexpected (! (one >= zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (one >= one)) fail ("STAmount fail");
|
unexpected (! (one >= one), "STAmount fail");
|
||||||
|
|
||||||
if ((one >= hundred)) fail ("STAmount fail");
|
unexpected ((one >= hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred >= zero)) fail ("STAmount fail");
|
unexpected (! (hundred >= zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred >= one)) fail ("STAmount fail");
|
unexpected (! (hundred >= one), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred >= hundred)) fail ("STAmount fail");
|
unexpected (! (hundred >= hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero == zero)) fail ("STAmount fail");
|
unexpected (! (zero == zero), "STAmount fail");
|
||||||
|
|
||||||
if ((zero == one)) fail ("STAmount fail");
|
unexpected ((zero == one), "STAmount fail");
|
||||||
|
|
||||||
if ((zero == hundred)) fail ("STAmount fail");
|
unexpected ((zero == hundred), "STAmount fail");
|
||||||
|
|
||||||
if ((one == zero)) fail ("STAmount fail");
|
unexpected ((one == zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (one == one)) fail ("STAmount fail");
|
unexpected (! (one == one), "STAmount fail");
|
||||||
|
|
||||||
if ((one == hundred)) fail ("STAmount fail");
|
unexpected ((one == hundred), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred == zero)) fail ("STAmount fail");
|
unexpected ((hundred == zero), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred == one)) fail ("STAmount fail");
|
unexpected ((hundred == one), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred == hundred)) fail ("STAmount fail");
|
unexpected (! (hundred == hundred), "STAmount fail");
|
||||||
|
|
||||||
if ((zero != zero)) fail ("STAmount fail");
|
unexpected ((zero != zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero != one)) fail ("STAmount fail");
|
unexpected (! (zero != one), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero != hundred)) fail ("STAmount fail");
|
unexpected (! (zero != hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (one != zero)) fail ("STAmount fail");
|
unexpected (! (one != zero), "STAmount fail");
|
||||||
|
|
||||||
if ((one != one)) fail ("STAmount fail");
|
unexpected ((one != one), "STAmount fail");
|
||||||
|
|
||||||
if (! (one != hundred)) fail ("STAmount fail");
|
unexpected (! (one != hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred != zero)) fail ("STAmount fail");
|
unexpected (! (hundred != zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred != one)) fail ("STAmount fail");
|
unexpected (! (hundred != one), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred != hundred)) fail ("STAmount fail");
|
unexpected ((hundred != hundred), "STAmount fail");
|
||||||
|
|
||||||
if (STAmount ().getText () != "0") fail ("STAmount fail");
|
unexpected (STAmount ().getText () != "0", "STAmount fail");
|
||||||
|
|
||||||
if (STAmount (31).getText () != "31") fail ("STAmount fail");
|
unexpected (STAmount (31).getText () != "31", "STAmount fail");
|
||||||
|
|
||||||
if (STAmount (310).getText () != "310") fail ("STAmount fail");
|
unexpected (STAmount (310).getText () != "310", "STAmount fail");
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
void testCustomCurrency ()
|
void testCustomCurrency ()
|
||||||
{
|
{
|
||||||
beginTest ("custom currency");
|
beginTestCase ("custom currency");
|
||||||
|
|
||||||
STAmount zero (CURRENCY_ONE, ACCOUNT_ONE), one (CURRENCY_ONE, ACCOUNT_ONE, 1), hundred (CURRENCY_ONE, ACCOUNT_ONE, 100);
|
STAmount zero (CURRENCY_ONE, ACCOUNT_ONE), one (CURRENCY_ONE, ACCOUNT_ONE, 1), hundred (CURRENCY_ONE, ACCOUNT_ONE, 100);
|
||||||
|
|
||||||
serializeAndDeserialize (one).getRaw ();
|
serializeAndDeserialize (one).getRaw ();
|
||||||
|
|
||||||
if (serializeAndDeserialize (zero) != zero) fail ("STAmount fail");
|
unexpected (serializeAndDeserialize (zero) != zero, "STAmount fail");
|
||||||
|
|
||||||
if (serializeAndDeserialize (one) != one) fail ("STAmount fail");
|
unexpected (serializeAndDeserialize (one) != one, "STAmount fail");
|
||||||
|
|
||||||
if (serializeAndDeserialize (hundred) != hundred) fail ("STAmount fail");
|
unexpected (serializeAndDeserialize (hundred) != hundred, "STAmount fail");
|
||||||
|
|
||||||
if (zero.isNative ()) fail ("STAmount fail");
|
unexpected (zero.isNative (), "STAmount fail");
|
||||||
|
|
||||||
if (hundred.isNative ()) fail ("STAmount fail");
|
unexpected (hundred.isNative (), "STAmount fail");
|
||||||
|
|
||||||
if (!zero.isZero ()) fail ("STAmount fail");
|
unexpected (!zero.isZero (), "STAmount fail");
|
||||||
|
|
||||||
if (one.isZero ()) fail ("STAmount fail");
|
unexpected (one.isZero (), "STAmount fail");
|
||||||
|
|
||||||
if (hundred.isZero ()) fail ("STAmount fail");
|
unexpected (hundred.isZero (), "STAmount fail");
|
||||||
|
|
||||||
if ((zero < zero)) fail ("STAmount fail");
|
unexpected ((zero < zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero < one)) fail ("STAmount fail");
|
unexpected (! (zero < one), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero < hundred)) fail ("STAmount fail");
|
unexpected (! (zero < hundred), "STAmount fail");
|
||||||
|
|
||||||
if ((one < zero)) fail ("STAmount fail");
|
unexpected ((one < zero), "STAmount fail");
|
||||||
|
|
||||||
if ((one < one)) fail ("STAmount fail");
|
unexpected ((one < one), "STAmount fail");
|
||||||
|
|
||||||
if (! (one < hundred)) fail ("STAmount fail");
|
unexpected (! (one < hundred), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred < zero)) fail ("STAmount fail");
|
unexpected ((hundred < zero), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred < one)) fail ("STAmount fail");
|
unexpected ((hundred < one), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred < hundred)) fail ("STAmount fail");
|
unexpected ((hundred < hundred), "STAmount fail");
|
||||||
|
|
||||||
if ((zero > zero)) fail ("STAmount fail");
|
unexpected ((zero > zero), "STAmount fail");
|
||||||
|
|
||||||
if ((zero > one)) fail ("STAmount fail");
|
unexpected ((zero > one), "STAmount fail");
|
||||||
|
|
||||||
if ((zero > hundred)) fail ("STAmount fail");
|
unexpected ((zero > hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (one > zero)) fail ("STAmount fail");
|
unexpected (! (one > zero), "STAmount fail");
|
||||||
|
|
||||||
if ((one > one)) fail ("STAmount fail");
|
unexpected ((one > one), "STAmount fail");
|
||||||
|
|
||||||
if ((one > hundred)) fail ("STAmount fail");
|
unexpected ((one > hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred > zero)) fail ("STAmount fail");
|
unexpected (! (hundred > zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred > one)) fail ("STAmount fail");
|
unexpected (! (hundred > one), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred > hundred)) fail ("STAmount fail");
|
unexpected ((hundred > hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero <= zero)) fail ("STAmount fail");
|
unexpected (! (zero <= zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero <= one)) fail ("STAmount fail");
|
unexpected (! (zero <= one), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero <= hundred)) fail ("STAmount fail");
|
unexpected (! (zero <= hundred), "STAmount fail");
|
||||||
|
|
||||||
if ((one <= zero)) fail ("STAmount fail");
|
unexpected ((one <= zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (one <= one)) fail ("STAmount fail");
|
unexpected (! (one <= one), "STAmount fail");
|
||||||
|
|
||||||
if (! (one <= hundred)) fail ("STAmount fail");
|
unexpected (! (one <= hundred), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred <= zero)) fail ("STAmount fail");
|
unexpected ((hundred <= zero), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred <= one)) fail ("STAmount fail");
|
unexpected ((hundred <= one), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred <= hundred)) fail ("STAmount fail");
|
unexpected (! (hundred <= hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero >= zero)) fail ("STAmount fail");
|
unexpected (! (zero >= zero), "STAmount fail");
|
||||||
|
|
||||||
if ((zero >= one)) fail ("STAmount fail");
|
unexpected ((zero >= one), "STAmount fail");
|
||||||
|
|
||||||
if ((zero >= hundred)) fail ("STAmount fail");
|
unexpected ((zero >= hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (one >= zero)) fail ("STAmount fail");
|
unexpected (! (one >= zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (one >= one)) fail ("STAmount fail");
|
unexpected (! (one >= one), "STAmount fail");
|
||||||
|
|
||||||
if ((one >= hundred)) fail ("STAmount fail");
|
unexpected ((one >= hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred >= zero)) fail ("STAmount fail");
|
unexpected (! (hundred >= zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred >= one)) fail ("STAmount fail");
|
unexpected (! (hundred >= one), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred >= hundred)) fail ("STAmount fail");
|
unexpected (! (hundred >= hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero == zero)) fail ("STAmount fail");
|
unexpected (! (zero == zero), "STAmount fail");
|
||||||
|
|
||||||
if ((zero == one)) fail ("STAmount fail");
|
unexpected ((zero == one), "STAmount fail");
|
||||||
|
|
||||||
if ((zero == hundred)) fail ("STAmount fail");
|
unexpected ((zero == hundred), "STAmount fail");
|
||||||
|
|
||||||
if ((one == zero)) fail ("STAmount fail");
|
unexpected ((one == zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (one == one)) fail ("STAmount fail");
|
unexpected (! (one == one), "STAmount fail");
|
||||||
|
|
||||||
if ((one == hundred)) fail ("STAmount fail");
|
unexpected ((one == hundred), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred == zero)) fail ("STAmount fail");
|
unexpected ((hundred == zero), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred == one)) fail ("STAmount fail");
|
unexpected ((hundred == one), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred == hundred)) fail ("STAmount fail");
|
unexpected (! (hundred == hundred), "STAmount fail");
|
||||||
|
|
||||||
if ((zero != zero)) fail ("STAmount fail");
|
unexpected ((zero != zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero != one)) fail ("STAmount fail");
|
unexpected (! (zero != one), "STAmount fail");
|
||||||
|
|
||||||
if (! (zero != hundred)) fail ("STAmount fail");
|
unexpected (! (zero != hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (one != zero)) fail ("STAmount fail");
|
unexpected (! (one != zero), "STAmount fail");
|
||||||
|
|
||||||
if ((one != one)) fail ("STAmount fail");
|
unexpected ((one != one), "STAmount fail");
|
||||||
|
|
||||||
if (! (one != hundred)) fail ("STAmount fail");
|
unexpected (! (one != hundred), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred != zero)) fail ("STAmount fail");
|
unexpected (! (hundred != zero), "STAmount fail");
|
||||||
|
|
||||||
if (! (hundred != one)) fail ("STAmount fail");
|
unexpected (! (hundred != one), "STAmount fail");
|
||||||
|
|
||||||
if ((hundred != hundred)) fail ("STAmount fail");
|
unexpected ((hundred != hundred), "STAmount fail");
|
||||||
|
|
||||||
if (STAmount (CURRENCY_ONE, ACCOUNT_ONE).getText () != "0") fail ("STAmount fail");
|
unexpected (STAmount (CURRENCY_ONE, ACCOUNT_ONE).getText () != "0", "STAmount fail");
|
||||||
|
|
||||||
if (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 31).getText () != "31") fail ("STAmount fail");
|
unexpected (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 31).getText () != "31", "STAmount fail");
|
||||||
|
|
||||||
if (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 31, 1).getText () != "310") fail ("STAmount fail");
|
unexpected (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 31, 1).getText () != "310", "STAmount fail");
|
||||||
|
|
||||||
if (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 31, -1).getText () != "3.1") fail ("STAmount fail");
|
unexpected (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 31, -1).getText () != "3.1", "STAmount fail");
|
||||||
|
|
||||||
if (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 31, -2).getText () != "0.31") fail ("STAmount fail");
|
unexpected (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 31, -2).getText () != "0.31", "STAmount fail");
|
||||||
|
|
||||||
if (STAmount::multiply (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 20), STAmount (3), CURRENCY_ONE, ACCOUNT_ONE).getText () != "60")
|
unexpected (STAmount::multiply (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 20), STAmount (3), CURRENCY_ONE, ACCOUNT_ONE).getText () != "60",
|
||||||
fail ("STAmount multiply fail 1");
|
"STAmount multiply fail 1");
|
||||||
|
|
||||||
if (STAmount::multiply (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 20), STAmount (3), uint160 (), ACCOUNT_XRP).getText () != "60")
|
unexpected (STAmount::multiply (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 20), STAmount (3), uint160 (), ACCOUNT_XRP).getText () != "60",
|
||||||
fail ("STAmount multiply fail 2");
|
"STAmount multiply fail 2");
|
||||||
|
|
||||||
if (STAmount::multiply (STAmount (20), STAmount (3), CURRENCY_ONE, ACCOUNT_ONE).getText () != "60")
|
unexpected (STAmount::multiply (STAmount (20), STAmount (3), CURRENCY_ONE, ACCOUNT_ONE).getText () != "60",
|
||||||
fail ("STAmount multiply fail 3");
|
"STAmount multiply fail 3");
|
||||||
|
|
||||||
if (STAmount::multiply (STAmount (20), STAmount (3), uint160 (), ACCOUNT_XRP).getText () != "60")
|
unexpected (STAmount::multiply (STAmount (20), STAmount (3), uint160 (), ACCOUNT_XRP).getText () != "60",
|
||||||
fail ("STAmount multiply fail 4");
|
"STAmount multiply fail 4");
|
||||||
|
|
||||||
if (STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount (3), CURRENCY_ONE, ACCOUNT_ONE).getText () != "20")
|
if (STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount (3), CURRENCY_ONE, ACCOUNT_ONE).getText () != "20")
|
||||||
{
|
{
|
||||||
@@ -1712,30 +1723,34 @@ public:
|
|||||||
STAmount (3), CURRENCY_ONE, ACCOUNT_ONE).getText ();
|
STAmount (3), CURRENCY_ONE, ACCOUNT_ONE).getText ();
|
||||||
fail ("STAmount divide fail");
|
fail ("STAmount divide fail");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pass ();
|
||||||
|
}
|
||||||
|
|
||||||
if (STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount (3), uint160 (), ACCOUNT_XRP).getText () != "20")
|
unexpected (STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount (3), uint160 (), ACCOUNT_XRP).getText () != "20",
|
||||||
fail ("STAmount divide fail");
|
"STAmount divide fail");
|
||||||
|
|
||||||
if (STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 3), CURRENCY_ONE, ACCOUNT_ONE).getText () != "20")
|
unexpected (STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 3), CURRENCY_ONE, ACCOUNT_ONE).getText () != "20",
|
||||||
fail ("STAmount divide fail");
|
"STAmount divide fail");
|
||||||
|
|
||||||
if (STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 3), uint160 (), ACCOUNT_XRP).getText () != "20")
|
unexpected (STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 3), uint160 (), ACCOUNT_XRP).getText () != "20",
|
||||||
fail ("STAmount divide fail");
|
"STAmount divide fail");
|
||||||
|
|
||||||
STAmount a1 (CURRENCY_ONE, ACCOUNT_ONE, 60), a2 (CURRENCY_ONE, ACCOUNT_ONE, 10, -1);
|
STAmount a1 (CURRENCY_ONE, ACCOUNT_ONE, 60), a2 (CURRENCY_ONE, ACCOUNT_ONE, 10, -1);
|
||||||
|
|
||||||
if (STAmount::divide (a2, a1, CURRENCY_ONE, ACCOUNT_ONE) != STAmount::setRate (STAmount::getRate (a1, a2)))
|
unexpected (STAmount::divide (a2, a1, CURRENCY_ONE, ACCOUNT_ONE) != STAmount::setRate (STAmount::getRate (a1, a2)),
|
||||||
fail ("STAmount setRate(getRate) fail");
|
"STAmount setRate(getRate) fail");
|
||||||
|
|
||||||
if (STAmount::divide (a1, a2, CURRENCY_ONE, ACCOUNT_ONE) != STAmount::setRate (STAmount::getRate (a2, a1)))
|
unexpected (STAmount::divide (a1, a2, CURRENCY_ONE, ACCOUNT_ONE) != STAmount::setRate (STAmount::getRate (a2, a1)),
|
||||||
fail ("STAmount setRate(getRate) fail");
|
"STAmount setRate(getRate) fail");
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
void testArithmetic ()
|
void testArithmetic ()
|
||||||
{
|
{
|
||||||
beginTest ("arithmetic");
|
beginTestCase ("arithmetic");
|
||||||
|
|
||||||
CBigNum b;
|
CBigNum b;
|
||||||
|
|
||||||
@@ -1751,34 +1766,38 @@ public:
|
|||||||
WriteLog (lsFATAL, STAmount) << r << " != " << b.getuint64 () << " " << b.ToString (16);
|
WriteLog (lsFATAL, STAmount) << r << " != " << b.getuint64 () << " " << b.ToString (16);
|
||||||
fail ("setull64/getull64 failure");
|
fail ("setull64/getull64 failure");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pass ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test currency multiplication and division operations such as
|
// Test currency multiplication and division operations such as
|
||||||
// convertToDisplayAmount, convertToInternalAmount, getRate, getClaimed, and getNeeded
|
// convertToDisplayAmount, convertToInternalAmount, getRate, getClaimed, and getNeeded
|
||||||
|
|
||||||
if (STAmount::getRate (STAmount (1), STAmount (10)) != (((100ull - 14) << (64 - 8)) | 1000000000000000ull))
|
unexpected (STAmount::getRate (STAmount (1), STAmount (10)) != (((100ull - 14) << (64 - 8)) | 1000000000000000ull),
|
||||||
fail ("STAmount getRate fail 1");
|
"STAmount getRate fail 1");
|
||||||
|
|
||||||
if (STAmount::getRate (STAmount (10), STAmount (1)) != (((100ull - 16) << (64 - 8)) | 1000000000000000ull))
|
unexpected (STAmount::getRate (STAmount (10), STAmount (1)) != (((100ull - 16) << (64 - 8)) | 1000000000000000ull),
|
||||||
fail ("STAmount getRate fail 2");
|
"STAmount getRate fail 2");
|
||||||
|
|
||||||
if (STAmount::getRate (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 1), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 10)) != (((100ull - 14) << (64 - 8)) | 1000000000000000ull))
|
unexpected (STAmount::getRate (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 1), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 10)) != (((100ull - 14) << (64 - 8)) | 1000000000000000ull),
|
||||||
fail ("STAmount getRate fail 3");
|
"STAmount getRate fail 3");
|
||||||
|
|
||||||
if (STAmount::getRate (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 10), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 1)) != (((100ull - 16) << (64 - 8)) | 1000000000000000ull))
|
unexpected (STAmount::getRate (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 10), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 1)) != (((100ull - 16) << (64 - 8)) | 1000000000000000ull),
|
||||||
fail ("STAmount getRate fail 4");
|
"STAmount getRate fail 4");
|
||||||
|
|
||||||
if (STAmount::getRate (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 1), STAmount (10)) != (((100ull - 14) << (64 - 8)) | 1000000000000000ull))
|
unexpected (STAmount::getRate (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 1), STAmount (10)) != (((100ull - 14) << (64 - 8)) | 1000000000000000ull),
|
||||||
fail ("STAmount getRate fail 5");
|
"STAmount getRate fail 5");
|
||||||
|
|
||||||
if (STAmount::getRate (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 10), STAmount (1)) != (((100ull - 16) << (64 - 8)) | 1000000000000000ull))
|
unexpected (STAmount::getRate (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 10), STAmount (1)) != (((100ull - 16) << (64 - 8)) | 1000000000000000ull),
|
||||||
fail ("STAmount getRate fail 6");
|
"STAmount getRate fail 6");
|
||||||
|
|
||||||
if (STAmount::getRate (STAmount (1), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 10)) != (((100ull - 14) << (64 - 8)) | 1000000000000000ull))
|
unexpected (STAmount::getRate (STAmount (1), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 10)) != (((100ull - 14) << (64 - 8)) | 1000000000000000ull),
|
||||||
fail ("STAmount getRate fail 7");
|
"STAmount getRate fail 7");
|
||||||
|
|
||||||
if (STAmount::getRate (STAmount (10), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 1)) != (((100ull - 16) << (64 - 8)) | 1000000000000000ull))
|
unexpected (STAmount::getRate (STAmount (10), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 1)) != (((100ull - 16) << (64 - 8)) | 1000000000000000ull),
|
||||||
fail ("STAmount getRate fail 8");
|
"STAmount getRate fail 8");
|
||||||
|
|
||||||
roundTest (1, 3, 3);
|
roundTest (1, 3, 3);
|
||||||
roundTest (2, 3, 9);
|
roundTest (2, 3, 9);
|
||||||
@@ -1795,7 +1814,7 @@ public:
|
|||||||
|
|
||||||
void testUnderflow ()
|
void testUnderflow ()
|
||||||
{
|
{
|
||||||
beginTest ("underflow");
|
beginTestCase ("underflow");
|
||||||
|
|
||||||
STAmount bigNative (STAmount::cMaxNative / 2);
|
STAmount bigNative (STAmount::cMaxNative / 2);
|
||||||
STAmount bigValue (CURRENCY_ONE, ACCOUNT_ONE,
|
STAmount bigValue (CURRENCY_ONE, ACCOUNT_ONE,
|
||||||
@@ -1843,7 +1862,7 @@ public:
|
|||||||
// Change this to actually do something.
|
// Change this to actually do something.
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
beginTest ("rounding ");
|
beginTestCase ("rounding ");
|
||||||
|
|
||||||
uint64 value = 25000000000000000ull;
|
uint64 value = 25000000000000000ull;
|
||||||
int offset = -14;
|
int offset = -14;
|
||||||
|
|||||||
@@ -1572,10 +1572,9 @@ public:
|
|||||||
|
|
||||||
void runTest ()
|
void runTest ()
|
||||||
{
|
{
|
||||||
beginTest ("serialization");
|
beginTestCase ("serialization");
|
||||||
|
|
||||||
if (sfGeneric.isUseful ())
|
unexpected (sfGeneric.isUseful (), "sfGeneric must not be useful");
|
||||||
fail ("sfGeneric must not be useful");
|
|
||||||
|
|
||||||
SField sfTestVL (STI_VL, 255, "TestVL");
|
SField sfTestVL (STI_VL, 255, "TestVL");
|
||||||
SField sfTestH256 (STI_HASH256, 255, "TestH256");
|
SField sfTestH256 (STI_HASH256, 255, "TestH256");
|
||||||
@@ -1591,16 +1590,16 @@ public:
|
|||||||
STObject object1 (elements, sfTestObject);
|
STObject object1 (elements, sfTestObject);
|
||||||
STObject object2 (object1);
|
STObject object2 (object1);
|
||||||
|
|
||||||
if (object1.getSerializer () != object2.getSerializer ()) fail ("STObject error 1");
|
unexpected (object1.getSerializer () != object2.getSerializer (), "STObject error 1");
|
||||||
|
|
||||||
if (object1.isFieldPresent (sfTestH256) || !object1.isFieldPresent (sfTestVL))
|
unexpected (object1.isFieldPresent (sfTestH256) || !object1.isFieldPresent (sfTestVL),
|
||||||
fail ("STObject error");
|
"STObject error");
|
||||||
|
|
||||||
object1.makeFieldPresent (sfTestH256);
|
object1.makeFieldPresent (sfTestH256);
|
||||||
|
|
||||||
if (!object1.isFieldPresent (sfTestH256)) fail ("STObject Error 2");
|
unexpected (!object1.isFieldPresent (sfTestH256), "STObject Error 2");
|
||||||
|
|
||||||
if (object1.getFieldH256 (sfTestH256) != uint256 ()) fail ("STObject error 3");
|
unexpected (object1.getFieldH256 (sfTestH256) != uint256 (), "STObject error 3");
|
||||||
|
|
||||||
if (object1.getSerializer () == object2.getSerializer ())
|
if (object1.getSerializer () == object2.getSerializer ())
|
||||||
{
|
{
|
||||||
@@ -1608,26 +1607,30 @@ public:
|
|||||||
WriteLog (lsINFO, STObject) << "O2: " << object2.getJson (0);
|
WriteLog (lsINFO, STObject) << "O2: " << object2.getJson (0);
|
||||||
fail ("STObject error 4");
|
fail ("STObject error 4");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pass ();
|
||||||
|
}
|
||||||
|
|
||||||
object1.makeFieldAbsent (sfTestH256);
|
object1.makeFieldAbsent (sfTestH256);
|
||||||
|
|
||||||
if (object1.isFieldPresent (sfTestH256)) fail ("STObject error 5");
|
unexpected (object1.isFieldPresent (sfTestH256), "STObject error 5");
|
||||||
|
|
||||||
if (object1.getFlags () != 0) fail ("STObject error 6");
|
unexpected (object1.getFlags () != 0, "STObject error 6");
|
||||||
|
|
||||||
if (object1.getSerializer () != object2.getSerializer ()) fail ("STObject error 7");
|
unexpected (object1.getSerializer () != object2.getSerializer (), "STObject error 7");
|
||||||
|
|
||||||
STObject copy (object1);
|
STObject copy (object1);
|
||||||
|
|
||||||
if (object1.isFieldPresent (sfTestH256)) fail ("STObject error 8");
|
unexpected (object1.isFieldPresent (sfTestH256), "STObject error 8");
|
||||||
|
|
||||||
if (copy.isFieldPresent (sfTestH256)) fail ("STObject error 9");
|
unexpected (copy.isFieldPresent (sfTestH256), "STObject error 9");
|
||||||
|
|
||||||
if (object1.getSerializer () != copy.getSerializer ()) fail ("STObject error 10");
|
unexpected (object1.getSerializer () != copy.getSerializer (), "STObject error 10");
|
||||||
|
|
||||||
copy.setFieldU32 (sfTestU32, 1);
|
copy.setFieldU32 (sfTestU32, 1);
|
||||||
|
|
||||||
if (object1.getSerializer () == copy.getSerializer ()) fail ("STObject error 11");
|
unexpected (object1.getSerializer () == copy.getSerializer (), "STObject error 11");
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
@@ -1641,9 +1644,9 @@ public:
|
|||||||
|
|
||||||
STObject object3 (elements, it, sfTestObject);
|
STObject object3 (elements, it, sfTestObject);
|
||||||
|
|
||||||
if (object1.getFieldVL (sfTestVL) != j) fail ("STObject error");
|
unexpected (object1.getFieldVL (sfTestVL) != j, "STObject error");
|
||||||
|
|
||||||
if (object3.getFieldVL (sfTestVL) != j) fail ("STObject error");
|
unexpected (object3.getFieldVL (sfTestVL) != j, "STObject error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -716,7 +716,7 @@ public:
|
|||||||
|
|
||||||
void runTest ()
|
void runTest ()
|
||||||
{
|
{
|
||||||
beginTest ("hash");
|
beginTestCase ("hash");
|
||||||
|
|
||||||
Serializer s1;
|
Serializer s1;
|
||||||
s1.add32 (3);
|
s1.add32 (3);
|
||||||
|
|||||||
Reference in New Issue
Block a user