Browse Source

Random code: Exceptions and outut

cl-refactor
Dimitry 10 years ago
parent
commit
ec0e65d339
  1. 8
      test/TestHelper.h
  2. 25
      test/fuzzTesting/createRandomTest.cpp

8
test/TestHelper.h

@ -33,10 +33,10 @@
#define DONTUSE_BOOST_MACROS
#ifdef DONTUSE_BOOST_MACROS
#define TBOOST_THROW_EXCEPTION(arg) throw;
#define TBOOST_REQUIRE(arg) if(arg == false) throw;
#define TBOOST_CHECK_MESSAGE(arg1, arg2) if(arg1 == false) throw;
#define TBOOST_WARN_MESSAGE(arg1, arg2) throw;
#define TBOOST_THROW_EXCEPTION(arg) throw dev::Exception();
#define TBOOST_REQUIRE(arg) if(arg == false) throw dev::Exception();
#define TBOOST_CHECK_MESSAGE(arg1, arg2) if(arg1 == false) throw dev::Exception();
#define TBOOST_WARN_MESSAGE(arg1, arg2) throw dev::Exception();
#else
#define TBOOST_THROW_EXCEPTION(arg) BOOST_THROW_EXCEPTION(arg)
#define TBOOST_REQUIRE(arg) BOOST_REQUIRE(arg)

25
test/fuzzTesting/createRandomTest.cpp

@ -63,11 +63,28 @@ int main(int argc, char *argv[])
void randomTransactionTest()
{
std::string newTest = c_testExampleTransactionTest;
parseTestWithTypes(newTest);
//redirect all output to the stream
std::ostringstream strCout;
std::streambuf* oldCoutStreamBuf = std::cout.rdbuf();
std::cout.rdbuf( strCout.rdbuf() );
std::cerr.rdbuf( strCout.rdbuf() );
json_spirit::mValue v;
json_spirit::read_string(newTest, v);
dev::test::doTransactionTests(v, true);
try
{
std::string newTest = c_testExampleTransactionTest;
parseTestWithTypes(newTest);
json_spirit::read_string(newTest, v);
dev::test::doTransactionTests(v, true);
}
catch(...)
{
std::cerr << "Test fill exception!";
}
//restroe output
std::cout.rdbuf(oldCoutStreamBuf);
std::cerr.rdbuf(oldCoutStreamBuf);
std::cout << json_spirit::write_string(v, true);
}

Loading…
Cancel
Save