unsigned int ParseScriptFlags(std::string strFlags)
{
    if (strFlags.empty()) {
        return 0;
    }
    unsigned int flags = 0;
    std::vector<std::string> words;
    boost::algorithm::split(words, strFlags, boost::algorithm::is_any_of(","));

    BOOST_FOREACH(std::string word, words)
    {
        if (!mapFlagNames.count(word))
            BOOST_ERROR("Bad test: unknown verification flag '" << word << "'");
        flags |= mapFlagNames[word];
    }

    return flags;
}
int test_main( int, char* [] )  // note the name!
{
    // six ways to detect and report the same error:
    BOOST_CHECK( add(2,2) == 4 );          // #1 continues on error

    BOOST_REQUIRE( add(2,2) == 4 );        // #2 throws on error

    if ( add(2,2) != 4 )
        BOOST_ERROR( "Ouch...");           // #3 continues on error

    if ( add(2,2) != 4 )
        BOOST_FAIL( "Ouch..." );           // #4 throws on error

    if ( add(2,2) != 4 )
        throw "Oops...";                   // #5 throws on error

    return add(2,2) == 4 ? 0 : 1;          // #6 returns error code
}
Пример #3
0
        int operator()(Tag)
        {
            saga::error err = (saga::error)E::value;

            equipment_.logical_file = equipment_.utils->create_temp_file_name(true);

            equipment_.logical_file.set_scheme("any");
            equipment_.replica_file = equipment_.utils->create_temp_file_for_exception(
                    (saga::error)E::value).get_url();

            // make sure the path doesn't contain a drive (on Windows)
            remove_drive(equipment_.logical_file);

            SAGA_REQUIRE_THROW(TestFunctor::test(Tag(), E(), equipment_), err);
            equipment_.utils->delete_temp_file(equipment_.logical_file);
            equipment_.utils->delete_temp_file(equipment_.replica_file);
            if(err != (saga::error)E::value)
            {
               std::string message("");
               message += "Test " + std::string(TestFunctor::name) + " with exception "
                       + std::string(saga::error_names[err]) 
                       + " expecting " + std::string(saga::error_names[E::value]) 
                       + " with threading ";
               if(boost::is_same<Threaded, boost::mpl::true_>::value)
                  message += "on";
               else
                  message += "off";
               message += " and api_type ";
               if(boost::is_same<Tag, saga::task_base::Sync>::value)
                  message += "Sync";
               else if(boost::is_same<Tag, saga::task_base::Async>::value)
                  message += "Async";
               else if(boost::is_same<Tag, saga::task_base::Task>::value)
                  message += "Task";
               else if(boost::is_same<Tag, PlainSync>::value)
                  message += "Plain";
               BOOST_ERROR(message.c_str());

            }
            equipment_.utils->delete_temp_file(equipment_.logical_file);
            return 0;
        }
Пример #4
0
void generic_complex_tests(std::complex<T> v)
{
    HASH_NAMESPACE::hash<std::complex<T> > complex_hasher;

    BOOST_TEST(complex_hasher(v) == complex_hasher(v));

    HASH_NAMESPACE::hash<T> real_hasher;
    T real = v.real();
    T imag = v.imag();

    BOOST_TEST(real_hasher(real) == complex_hasher(std::complex<T>(real)));

    if(imag != 0 && real_hasher(real) == complex_hasher(v)) {
        std::ostringstream os;
        os<<"real_hasher("<<real<<") == complex_hasher("
            <<v.real()<<" + "<<v.imag()<<"i) == "
            <<real_hasher(real)<<" (This might not be a bug).";
        BOOST_ERROR(os.str().c_str());
    }
}
int main()
{
    boost::shared_ptr< void const volatile > pv( new X );
    boost::shared_ptr< void > pv2 = boost::const_pointer_cast< void >( pv );
    boost::shared_ptr< X > px = boost::static_pointer_cast< X >( pv2 );

    try
    {
        boost::shared_ptr< X > qx = px->shared_from_this();

        BOOST_TEST( px == qx );
        BOOST_TEST( !( px < qx ) && !( qx < px ) );
    }
    catch( boost::bad_weak_ptr const& )
    {
        BOOST_ERROR( "px->shared_from_this() failed" );
    }

    return boost::report_errors();
}
Пример #6
0
void F::start_client()
{
  std::unique_lock <std::mutex> lock (mutex);

  while (!initialized && !terminate) {
    client = std::shared_ptr <WebSocketClient> (new WebSocketClient() );

    client->clear_access_channels (websocketpp::log::alevel::all);
    client->clear_error_channels (websocketpp::log::elevel::all);

    // Register our handlers
    client->set_open_handler (std::bind (&F::on_open, this,
                                         std::placeholders::_1) );
    client->set_message_handler (std::bind (&F::on_message, this,
                                            std::placeholders::_1, std::placeholders::_2) );

    // Initialize ASIO
    client->init_asio();

    // We expect there to be a lot of errors, so suppress them
    websocketpp::lib::error_code ec;
    WebSocketClient::connection_ptr con = client->get_connection (uri, ec);

    if (ec) {
      BOOST_ERROR (ec.message() );
    }

    client->connect (con);

    // Start the ASIO io_service run loop
    mutex.unlock();
    client->run();

    if (!initialized) {
      std::this_thread::sleep_for (std::chrono::milliseconds (50) );
    }

    mutex.lock();
  }
}
Пример #7
0
int main() {
    BOOST_TEST(type::instances == 0);
    try {
        boost::make_shared<type[]>(6);
        BOOST_ERROR("make_shared did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }
    BOOST_TEST(type::instances == 0);
    try {
        boost::make_shared<type[][2]>(3);
        BOOST_ERROR("make_shared did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
    BOOST_TEST(type::instances == 0);
    try {
        boost::make_shared<type[6]>();
        BOOST_ERROR("make_shared did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }
    BOOST_TEST(type::instances == 0);
    try {
        boost::make_shared<type[3][2]>();
        BOOST_ERROR("make_shared did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }
#endif
    BOOST_TEST(type::instances == 0);
    try {
        boost::make_shared_noinit<type[]>(6);
        BOOST_ERROR("make_shared_noinit did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }
    BOOST_TEST(type::instances == 0);
    try {
        boost::make_shared_noinit<type[][2]>(3);
        BOOST_ERROR("make_shared_noinit did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }
    return boost::report_errors();
}
Пример #8
0
int main() {
    BOOST_TEST(type::instances == 0);
    try {
        boost::allocate_shared<type[]>(std::allocator<type>(), 6);
        BOOST_ERROR("allocate_shared did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }
    BOOST_TEST(type::instances == 0);
    try {
        boost::allocate_shared<type[][2]>(std::allocator<type>(), 3);
        BOOST_ERROR("allocate_shared did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
    BOOST_TEST(type::instances == 0);
    try {
        boost::allocate_shared<type[6]>(std::allocator<type>());
        BOOST_ERROR("allocate_shared did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }
    BOOST_TEST(type::instances == 0);
    try {
        boost::allocate_shared<type[3][2]>(std::allocator<type>());
        BOOST_ERROR("allocate_shared did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }
#endif
    BOOST_TEST(type::instances == 0);
    try {
        boost::allocate_shared_noinit<type[]>(std::allocator<type>(), 6);
        BOOST_ERROR("allocate_shared_noinit did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }
    BOOST_TEST(type::instances == 0);
    try {
        boost::allocate_shared_noinit<type[][2]>(std::allocator<type>(), 3);
        BOOST_ERROR("allocate_shared_noinit did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }
    return boost::report_errors();
}
Пример #9
0
    void test_common ( _Contr &     contr      ,
                       size_t       sz_test    ,
                       size_t       n_dupl_add ,
                       bool         is_unique  )
    {
        if ( contr.size() < size_test_min() )
        {
            BOOST_ERROR ( "\n  !: ERROR invalid input ;\n" ) ;
            return ;
        }

        const size_t    n_dupl_test = is_unique ? 1 : n_dupl_add ;

        size         ( contr , sz_test , n_dupl_test ) ;
        max_size     ( contr ) ;
        clear_copy   ( contr ) ;
        begin_end    ( contr ) ;
        erase        ( contr ) ;
        swap         ( contr ) ;
        split        ( contr ) ;
        rel_operators( contr ) ;
    }
Пример #10
0
inline void et_CORBA_SystemException( const CORBA::SystemException & e ) {
	std::ostringstream os;
	os<<"CORBA system exception: ";
#if defined(MICO_VERSION)
	e._print(os);
#elif defined(OMNIORB_DIST_DATE)
	os<<"minor: "<<e.NP_minorString()<<"; completed: ";
	switch(e.completed()) {
	case CORBA::COMPLETED_YES: os<<"YES"; break;
	case CORBA::COMPLETED_NO: os<<"NO"; break;
	default: os<<"MAYBE";
	}
#else
	os<<"minor: "<<e.minor()<<"; completed: ";
	switch(e.completed()) {
	case CORBA::COMPLETED_YES: os<<"YES"; break;
	case CORBA::COMPLETED_NO: os<<"NO"; break;
	default: os<<"MAYBE";
	}
#endif
	BOOST_ERROR(os.str());
}
Пример #11
0
int main()
{
    boost::shared_ptr<X> px( new X );

    {
        boost::shared_ptr<X> px2( px.get(), null_deleter );
        BOOST_TEST( px == px2 );
    }

    try
    {
        boost::shared_ptr< X > qx = px->shared_from_this();

        BOOST_TEST( px == qx );
        BOOST_TEST( !( px < qx ) && !( qx < px ) );
    }
    catch( boost::bad_weak_ptr const& )
    {
        BOOST_ERROR( "px->shared_from_this() failed" );
    }

    return boost::report_errors();
}
Пример #12
0
int 
test_main( int /*argc*/, char* /*argv*/[] ) 
{
    int i = 1;

    BOOST_CHECK( i == 1 );
    BOOST_CHECK( i == 2 );

    BOOST_CHECK( bool_convertible1( true  ) );
    BOOST_CHECK( bool_convertible1( false ) );

    BOOST_CHECK( bool_convertible2( 1 ) );
    BOOST_CHECK( bool_convertible2( 0 ) );

    BOOST_CHECK( bool_convertible3( (void*)1 ) );
    BOOST_CHECK( bool_convertible3( NULL ) );

    BOOST_ERROR( "Some error" );

    BOOST_REQUIRE( i == 4 );

    return 0;
}
Пример #13
0
int main()
{
    BOOST_TEST( X::instances == 0 );

    {
        boost::shared_ptr< X > px = boost::allocate_shared< X >( std::allocator<void>() );
        BOOST_TEST( X::instances == 1 );

        try
        {
            boost::shared_ptr< X > qx = px->shared_from_this();

            BOOST_TEST( px == qx );
            BOOST_TEST( !( px < qx ) && !( qx < px ) );

            px.reset();
            BOOST_TEST( X::instances == 1 );
        }
        catch( boost::bad_weak_ptr const& )
        {
            BOOST_ERROR( "px->shared_from_this() failed" );
        }
    }

    BOOST_TEST( X::instances == 0 );

    {
        boost::shared_ptr< X > px = boost::allocate_shared< X >( std::allocator<void>(), 1 );
        BOOST_TEST( X::instances == 1 );

        try
        {
            boost::shared_ptr< X > qx = px->shared_from_this();

            BOOST_TEST( px == qx );
            BOOST_TEST( !( px < qx ) && !( qx < px ) );

            px.reset();
            BOOST_TEST( X::instances == 1 );
        }
        catch( boost::bad_weak_ptr const& )
        {
            BOOST_ERROR( "px->shared_from_this() failed" );
        }
    }

    BOOST_TEST( X::instances == 0 );

    {
        boost::shared_ptr< X > px = boost::allocate_shared< X >( std::allocator<void>(), 1, 2 );
        BOOST_TEST( X::instances == 1 );

        try
        {
            boost::shared_ptr< X > qx = px->shared_from_this();

            BOOST_TEST( px == qx );
            BOOST_TEST( !( px < qx ) && !( qx < px ) );

            px.reset();
            BOOST_TEST( X::instances == 1 );
        }
        catch( boost::bad_weak_ptr const& )
        {
            BOOST_ERROR( "px->shared_from_this() failed" );
        }
    }

    BOOST_TEST( X::instances == 0 );

    {
        boost::shared_ptr< X > px = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3 );
        BOOST_TEST( X::instances == 1 );

        try
        {
            boost::shared_ptr< X > qx = px->shared_from_this();

            BOOST_TEST( px == qx );
            BOOST_TEST( !( px < qx ) && !( qx < px ) );

            px.reset();
            BOOST_TEST( X::instances == 1 );
        }
        catch( boost::bad_weak_ptr const& )
        {
            BOOST_ERROR( "px->shared_from_this() failed" );
        }
    }

    BOOST_TEST( X::instances == 0 );

    {
        boost::shared_ptr< X > px = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4 );
        BOOST_TEST( X::instances == 1 );

        try
        {
            boost::shared_ptr< X > qx = px->shared_from_this();

            BOOST_TEST( px == qx );
            BOOST_TEST( !( px < qx ) && !( qx < px ) );

            px.reset();
            BOOST_TEST( X::instances == 1 );
        }
        catch( boost::bad_weak_ptr const& )
        {
            BOOST_ERROR( "px->shared_from_this() failed" );
        }
    }

    BOOST_TEST( X::instances == 0 );

    {
        boost::shared_ptr< X > px = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4, 5 );
        BOOST_TEST( X::instances == 1 );

        try
        {
            boost::shared_ptr< X > qx = px->shared_from_this();

            BOOST_TEST( px == qx );
            BOOST_TEST( !( px < qx ) && !( qx < px ) );

            px.reset();
            BOOST_TEST( X::instances == 1 );
        }
        catch( boost::bad_weak_ptr const& )
        {
            BOOST_ERROR( "px->shared_from_this() failed" );
        }
    }

    BOOST_TEST( X::instances == 0 );

    {
        boost::shared_ptr< X > px = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4, 5, 6 );
        BOOST_TEST( X::instances == 1 );

        try
        {
            boost::shared_ptr< X > qx = px->shared_from_this();

            BOOST_TEST( px == qx );
            BOOST_TEST( !( px < qx ) && !( qx < px ) );

            px.reset();
            BOOST_TEST( X::instances == 1 );
        }
        catch( boost::bad_weak_ptr const& )
        {
            BOOST_ERROR( "px->shared_from_this() failed" );
        }
    }

    BOOST_TEST( X::instances == 0 );

    {
        boost::shared_ptr< X > px = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4, 5, 6, 7 );
        BOOST_TEST( X::instances == 1 );

        try
        {
            boost::shared_ptr< X > qx = px->shared_from_this();

            BOOST_TEST( px == qx );
            BOOST_TEST( !( px < qx ) && !( qx < px ) );

            px.reset();
            BOOST_TEST( X::instances == 1 );
        }
        catch( boost::bad_weak_ptr const& )
        {
            BOOST_ERROR( "px->shared_from_this() failed" );
        }
    }

    BOOST_TEST( X::instances == 0 );

    {
        boost::shared_ptr< X > px = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4, 5, 6, 7, 8 );
        BOOST_TEST( X::instances == 1 );

        try
        {
            boost::shared_ptr< X > qx = px->shared_from_this();

            BOOST_TEST( px == qx );
            BOOST_TEST( !( px < qx ) && !( qx < px ) );

            px.reset();
            BOOST_TEST( X::instances == 1 );
        }
        catch( boost::bad_weak_ptr const& )
        {
            BOOST_ERROR( "px->shared_from_this() failed" );
        }
    }

    BOOST_TEST( X::instances == 0 );

    {
        boost::shared_ptr< X > px = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4, 5, 6, 7, 8, 9 );
        BOOST_TEST( X::instances == 1 );

        try
        {
            boost::shared_ptr< X > qx = px->shared_from_this();

            BOOST_TEST( px == qx );
            BOOST_TEST( !( px < qx ) && !( qx < px ) );

            px.reset();
            BOOST_TEST( X::instances == 1 );
        }
        catch( boost::bad_weak_ptr const& )
        {
            BOOST_ERROR( "px->shared_from_this() failed" );
        }
    }

    BOOST_TEST( X::instances == 0 );

    return boost::report_errors();
}
Пример #14
0
void doVMTests(json_spirit::mValue& v, bool _fillin)
{
	processCommandLineOptions();

	for (auto& i: v.get_obj())
	{
		cnote << i.first;
		mObject& o = i.second.get_obj();

		BOOST_REQUIRE(o.count("env") > 0);
		BOOST_REQUIRE(o.count("pre") > 0);
		BOOST_REQUIRE(o.count("exec") > 0);

		FakeExtVM fev;
		fev.importEnv(o["env"].get_obj());
		fev.importState(o["pre"].get_obj());

		if (_fillin)
			o["pre"] = mValue(fev.exportState());

		fev.importExec(o["exec"].get_obj());
		if (fev.code.empty())
		{
			fev.thisTxCode = get<3>(fev.addresses.at(fev.myAddress));
			fev.code = fev.thisTxCode;
		}

		bytes output;
		u256 gas;
		bool vmExceptionOccured = false;
		auto startTime = std::chrono::high_resolution_clock::now();
		try
		{
			auto vm = eth::VMFactory::create(fev.gas);
			output = vm->go(fev, fev.simpleTrace()).toBytes();
			gas = vm->gas();
		}
		catch (VMException const& _e)
		{
			cnote << "Safe VM Exception";
			vmExceptionOccured = true;
		}
		catch (Exception const& _e)
		{
			cnote << "VM did throw an exception: " << diagnostic_information(_e);
			BOOST_ERROR("Failed VM Test with Exception: " << _e.what());
		}
		catch (std::exception const& _e)
		{
			cnote << "VM did throw an exception: " << _e.what();
			BOOST_ERROR("Failed VM Test with Exception: " << _e.what());
		}

		auto endTime = std::chrono::high_resolution_clock::now();
		auto argc = boost::unit_test::framework::master_test_suite().argc;
		auto argv = boost::unit_test::framework::master_test_suite().argv;
		for (auto i = 0; i < argc; ++i)
		{	       
			if (std::string(argv[i]) == "--show-times")
			{
				auto testDuration = endTime - startTime;
				cnote << "Execution time: "
				      << std::chrono::duration_cast<std::chrono::milliseconds>(testDuration).count()
				      << " ms";
				break;
			}
		}

		// delete null entries in storage for the sake of comparison

		for (auto  &a: fev.addresses)
		{
			vector<u256> keystoDelete;
			for (auto &s: get<2>(a.second))
			{
				if (s.second == 0)
					keystoDelete.push_back(s.first);
			}
			for (auto const key: keystoDelete )
			{
				get<2>(a.second).erase(key);
			}
		}


		if (_fillin)
		{
			o["env"] = mValue(fev.exportEnv());
			o["exec"] = mValue(fev.exportExec());
			if (!vmExceptionOccured)
			{
				o["post"] = mValue(fev.exportState());
				o["callcreates"] = fev.exportCallCreates();
				o["out"] = "0x" + toHex(output);
				fev.push(o, "gas", gas);
				o["logs"] = exportLog(fev.sub.logs);
			}
		}
		else
		{
			if (o.count("post") > 0)	// No exceptions expected
			{
				BOOST_CHECK(!vmExceptionOccured);

				BOOST_REQUIRE(o.count("post") > 0);
				BOOST_REQUIRE(o.count("callcreates") > 0);
				BOOST_REQUIRE(o.count("out") > 0);
				BOOST_REQUIRE(o.count("gas") > 0);
				BOOST_REQUIRE(o.count("logs") > 0);

				dev::test::FakeExtVM test;
				test.importState(o["post"].get_obj());
				test.importCallCreates(o["callcreates"].get_array());
				test.sub.logs = importLog(o["logs"].get_array());

				checkOutput(output, o);

				BOOST_CHECK_EQUAL(toInt(o["gas"]), gas);

				auto& expectedAddrs = test.addresses;
				auto& resultAddrs = fev.addresses;
				for (auto&& expectedPair : expectedAddrs)
				{
					auto& expectedAddr = expectedPair.first;
					auto resultAddrIt = resultAddrs.find(expectedAddr);
					if (resultAddrIt == resultAddrs.end())
						BOOST_ERROR("Missing expected address " << expectedAddr);
					else
					{
						auto& expectedState = expectedPair.second;
						auto& resultState = resultAddrIt->second;
						BOOST_CHECK_MESSAGE(std::get<0>(expectedState) == std::get<0>(resultState), expectedAddr << ": incorrect balance " << std::get<0>(resultState) << ", expected " << std::get<0>(expectedState));
						BOOST_CHECK_MESSAGE(std::get<1>(expectedState) == std::get<1>(resultState), expectedAddr << ": incorrect txCount " << std::get<1>(resultState) << ", expected " << std::get<1>(expectedState));
						BOOST_CHECK_MESSAGE(std::get<3>(expectedState) == std::get<3>(resultState), expectedAddr << ": incorrect code");

						checkStorage(std::get<2>(expectedState), std::get<2>(resultState), expectedAddr);
					}
				}

				checkAddresses<std::map<Address, std::tuple<u256, u256, std::map<u256, u256>, bytes> > >(test.addresses, fev.addresses);
				BOOST_CHECK(test.callcreates == fev.callcreates);

				checkLog(fev.sub.logs, test.sub.logs);
			}
			else	// Exception expected
				BOOST_CHECK(vmExceptionOccured);
		}
	}
}
 void
 onReadTimeout(const ndn::Interest& interest)
 {
   BOOST_ERROR("Insert not successfull or Read data does not successfull");
 }
Пример #16
0
 HRESULT OnConfirmOverwrite(
     BSTR /*bstrOldFile*/, BSTR /*bstrNewFile*/)
 {
     BOOST_ERROR("Unexpected call to "__FUNCTION__);
     return E_NOTIMPL;
 }
Пример #17
0
inline void et_vq_except( const vq::except &e ) {
	std::ostringstream os;
	os<<"Exception: "<<e.what<<" in "<<e.file<<" at "<<e.line;
	BOOST_ERROR(os.str());
}
Пример #18
0
 BOOST_CATCH(...){
     BOOST_ERROR("failed with uncaught exception:");
 }
void
ClientHandler::check_not_duplicated_event()
{
  Json::Value request;
  Json::Value response;
  Json::Value params;
  std::string sessionId;
  std::string subscriptionId, subscriptionId2;
  std::string receivedId, responseId;

  request["jsonrpc"] = "2.0";
  request["id"] = getId();
  request["method"] = "subscribe";

  params["object"] = "manager_ServerManager";
  params["type"] = "ObjectCreated";

  request["params"] = params;

  response = sendRequest (request);

  BOOST_CHECK (response.isMember ("result") );
  BOOST_CHECK (response["result"].isObject() );
  BOOST_CHECK (response["result"].isMember ("sessionId") );
  sessionId = response["result"]["sessionId"].asString();
  BOOST_CHECK (response["result"].isMember ("value") );
  BOOST_CHECK (response["result"].isMember ("value") );
  subscriptionId = response["result"]["value"].asString();
  BOOST_CHECK (!subscriptionId.empty() );

  params["sessionId"] = sessionId;
  request["params"] = params;
  request["id"] = getId();

  response = sendRequest (request);

  BOOST_CHECK (response.isMember ("result") );
  BOOST_CHECK (response["result"].isObject() );
  BOOST_CHECK (response["result"].isMember ("sessionId") );
  BOOST_CHECK (sessionId == response["result"]["sessionId"].asString() );
  BOOST_CHECK (response["result"].isMember ("value") );
  subscriptionId2 = response["result"]["value"].asString();
  BOOST_CHECK (!subscriptionId2.empty() );

  BOOST_CHECK (subscriptionId != subscriptionId2);

  std::thread listener ([this, &receivedId] () {
    try {
      Json::Value event = this->waifForEvent (std::chrono::seconds (2) );
      receivedId = get_id_from_event (event);
    } catch (kurento::KurentoException e) {
      BOOST_FAIL ("Expected event not received");
    }

    try {
      this->waifForEvent (std::chrono::seconds (2) );
      BOOST_FAIL ("Unexpected event");
    } catch (kurento::KurentoException e) {
    }
  });

  request.clear();
  request["jsonrpc"] = "2.0";
  request["id"] = getId();
  request["method"] = "create";

  params.clear();
  params["type"] = "MediaPipeline";
  params["sessionId"] = sessionId;
  request["params"] = params;

  response = sendRequest (request);

  BOOST_CHECK (response.isMember ("result") );
  BOOST_CHECK (response["result"].isObject() );
  BOOST_CHECK (response["result"].isMember ("sessionId") );
  BOOST_CHECK (sessionId == response["result"]["sessionId"].asString() );
  BOOST_CHECK (response["result"].isMember ("value") );

  responseId = response["result"]["value"].asString();

  listener.join();

  BOOST_CHECK (receivedId == responseId);

  // Unsubscribe first listener and wait for event

  request.clear();
  request["jsonrpc"] = "2.0";
  request["id"] = getId();
  request["method"] = "unsubscribe";

  params.clear();
  params["object"] = "manager_ServerManager";
  params["subscription"] = subscriptionId;
  params["sessionId"] = sessionId;

  request["params"] = params;

  response = sendRequest (request);

  BOOST_CHECK (response.isMember ("result") );
  BOOST_CHECK (response["result"].isObject() );
  BOOST_CHECK (response["result"].isMember ("sessionId") );
  BOOST_CHECK (sessionId == response["result"]["sessionId"].asString() );

  std::thread listener2 ([this, &receivedId] () {
    try {
      Json::Value event = this->waifForEvent (std::chrono::seconds (2) );
      receivedId = get_id_from_event (event);
    } catch (kurento::KurentoException e) {
      BOOST_FAIL ("Expected event not received");
    }

    try {
      this->waifForEvent (std::chrono::seconds (2) );
      BOOST_FAIL ("Unexpected event");
    } catch (kurento::KurentoException e) {
    }
  });

  request.clear();
  request["jsonrpc"] = "2.0";
  request["id"] = getId();
  request["method"] = "create";

  params.clear();
  params["type"] = "MediaPipeline";
  params["sessionId"] = sessionId;
  request["params"] = params;

  response = sendRequest (request);

  BOOST_CHECK (response.isMember ("result") );
  BOOST_CHECK (response["result"].isObject() );
  BOOST_CHECK (response["result"].isMember ("sessionId") );
  BOOST_CHECK (sessionId == response["result"]["sessionId"].asString() );
  BOOST_CHECK (response["result"].isMember ("value") );
  BOOST_CHECK (response["result"].isMember ("value") );

  responseId = response["result"]["value"].asString();

  listener2.join();

  BOOST_CHECK (receivedId == responseId);

  request.clear();
  request["jsonrpc"] = "2.0";
  request["id"] = getId();
  request["method"] = "unsubscribe";

  params.clear();
  params["object"] = "manager_ServerManager";
  params["subscription"] = subscriptionId2;
  params["sessionId"] = sessionId;

  request["params"] = params;

  response = sendRequest (request);

  BOOST_CHECK (response.isMember ("result") );
  BOOST_CHECK (response["result"].isObject() );
  BOOST_CHECK (response["result"].isMember ("sessionId") );
  BOOST_CHECK (sessionId == response["result"]["sessionId"].asString() );

  std::thread listener3 ([this] () {
    try {
      Json::Value event = this->waifForEvent (std::chrono::seconds (2) );
      BOOST_ERROR ("Unexpected event: " + event.toStyledString() );
    } catch (kurento::KurentoException e) {
    }
  });

  request.clear();
  request["jsonrpc"] = "2.0";
  request["id"] = getId();
  request["method"] = "create";

  params.clear();
  params["type"] = "MediaPipeline";
  params["sessionId"] = sessionId;
  request["params"] = params;

  response = sendRequest (request);

  BOOST_CHECK (response.isMember ("result") );
  BOOST_CHECK (response["result"].isObject() );
  BOOST_CHECK (response["result"].isMember ("sessionId") );
  BOOST_CHECK (sessionId == response["result"]["sessionId"].asString() );
  BOOST_CHECK (response["result"].isMember ("value") );

  std::cout << response["result"]["value"].toStyledString() << std::endl;

  listener3.join();

  // Unsubscribe second listener and no event should be received
}
Пример #20
0
 void test(X const& x) const {
     if(!(x.size() == values_.size() &&
             std::equal(x.cbegin(), x.cend(), values_.begin(),
                 test::equivalent)))
         BOOST_ERROR("Strong exception safety failure.");
 }
// Simple test case 2
void test_case2() {
  if (1 != 2) {
    BOOST_ERROR ("Test case 2 failing...");
  }
}
Пример #22
0
    /**
     * Add domain. Create users as specified in configuration file.
     * For each users create many configuration entries as specified
     * in configuration file. For each pair user,pfix call user_conf_ls
     * and check whether it returns all entries as in configuration
     * file. Also for each pair call user_conf_ls_by_type and check results.
     * Remove domain.
     */
    void case10() {
        const char * dom = "case10.pl";
        std_try {
            typedef std::deque< std::string > string_array;
            CORBA::String_var dom_id;
            test_dom_user_add(dom, dom_id);

            string_array conf;
            std::ifstream ifs("data/case10/conf");
            BOOST_REQUIRE(sys::getlines<std::string>(ifs, conf));
            ifs.close();

            ::vq::ivq::auth_info ai;
            ai.id_domain = dom_id;
            ai.pass = static_cast<const char *>("asdasd");
            ai.flags = 0;

            string_array::const_iterator bc, be, fc, fe, pfix;
            string_array fields, uia;
            ::vq::ivq::user_conf_info ui;

            for( bc=conf.begin(), be=conf.end(); bc!=be; ++bc ) {
                if( '#' == (*bc)[0] ) continue;
                fields = text::split(*bc, " ");
                fc = fields.begin();
                fe = fields.end();
                BOOST_REQUIRE(fc != fe);
                ai.login = fc->c_str();

                err = auth->user_add(ai, FALSE);
                if( err->ec != ::vq::ivq::err_no
                && err->ec != ::vq::ivq::err_exists ) {
                    BOOST_ERROR(error2str(err));
                }

                ++fc;
                if( fc == fe ) continue;

                for( pfix=fc, ++fc; fc!=fe; ++fc )  {
                    uia = text::split(*fc, ",");
                    BOOST_REQUIRE(uia.size() == 2);
                    ui.type = boost::lexical_cast<CORBA::UShort>
                              (uia[0].c_str());
                    ui.val = uia[1].c_str();
                    IVQ_ERROR_EQUAL( auth->user_conf_add(dom_id,
                                                         ai.login, pfix->c_str(), ui),
                                     ::vq::ivq::err_no);
                }
            }

            for( bc=conf.begin(), be=conf.end(); bc!=be; ++bc ) {
                if( '#' == (*bc)[0] ) continue;
                fields = text::split(*bc, " ");
                fc = fields.begin();
                fe = fields.end();
                ai.login = fc->c_str();

                ++fc;
                if( fc == fe ) continue;

                pfix = fc++;

                ::vq::ivq::user_conf_info_list_var uis;
                IVQ_ERROR_EQUAL(auth->user_conf_ls(dom_id,
                                                   ai.login, pfix->c_str(), uis ),
                                ::vq::ivq::err_no );

                BOOST_CHECK_EQUAL(uis->length(), fields.size()-2);

                for( ; fc!=fe; ++fc )  {
                    uia = text::split(*fc, ",");
                    ui.type = boost::lexical_cast<CORBA::UShort>
                              (uia[0].c_str());
                    ui.val = uia[1].c_str();
                    bool has = false;
                    CORBA::ULong type_cnt=0;
                    for( CORBA::ULong i=0, s=uis->length();
                            i<s; ++i ) {
                        if( uis[i].type == ui.type ) {
                            ++type_cnt;
                            if(  uis[i].val == ui.val )
                                has = true;
                        }
                    }
                    BOOST_CHECK(has);

                    ::vq::ivq::user_conf_info_list_var uistype;
                    IVQ_ERROR_EQUAL(auth->user_conf_ls_by_type(dom_id,
                                    ai.login, pfix->c_str(), ui.type, uistype ),
                                    ::vq::ivq::err_no );

                    BOOST_CHECK_EQUAL(uistype->length(), type_cnt);
                    has = false;
                    for( CORBA::ULong i=0, s=uistype->length();
                            i<s; ++i ) {
                        if( uistype[i].type == ui.type
                                && uistype[i].val == ui.val ) {
                            has = true;
                            break;
                        }
                    }
                    BOOST_CHECK(has);
                }
            }
        } std_catch
        test_dom_rm(dom);
    }
void test_named_subexpressions(charT)
{
   //
   // Really this is just a test that the overloaded access functions work correctly:
   //
   static const charT e[] = 
   {
      '(', '?', '\'', 'o', 'n', 'e', '\'', 'a', '+', ')', '(', '?', '<', 't', 'w', 'o', '>', 'b', '+', ')', '\0'
   };
   static const charT t[] = 
   {
      'm', 'm', 'a', 'a', 'a', 'b', 'b', 'n', 'n', '\0'
   };
   static const charT one[] = 
   {
      'o', 'n', 'e', '\0'
   };
   static const charT two[] = 
   {
      't', 'w', 'o', '\0'
   };
   static const std::basic_string<charT> s_one(one);
   static const std::basic_string<charT> s_two(two);
   static const charT result1[] = { 'a', 'a', 'a', '\0' };
   static const charT result2[] = { 'b', 'b', '\0' };
   static const std::basic_string<charT> s_result1(result1);
   static const std::basic_string<charT> s_result2(result2);

   static const char* c_one = "one";
   static const char* c_two = "two";
   static const std::string cs_one(c_one);
   static const std::string cs_two(c_two);

   boost::basic_regex<charT> expression(e);
   boost::match_results<const charT*> what;
   if(regex_search(t, what, expression))
   {
      BOOST_CHECK(what.length(1) == 3);
      BOOST_CHECK(what.length(one) == 3);
      BOOST_CHECK(what.length(s_one) == 3);
      BOOST_CHECK(what.length(c_one) == 3);
      BOOST_CHECK(what.length(cs_one) == 3);
      BOOST_CHECK(what.position(1) == 2);
      BOOST_CHECK(what.position(one) == 2);
      BOOST_CHECK(what.position(s_one) == 2);
      BOOST_CHECK(what.position(c_one) == 2);
      BOOST_CHECK(what.position(cs_one) == 2);
      BOOST_CHECK(what.str(1) == s_result1);
      BOOST_CHECK(what.str(one) == s_result1);
      BOOST_CHECK(what.str(s_one) == s_result1);
      BOOST_CHECK(what.str(c_one) == s_result1);
      BOOST_CHECK(what.str(cs_one) == s_result1);
      BOOST_CHECK(what[1] == s_result1);
      BOOST_CHECK(what[one] == s_result1);
      BOOST_CHECK(what[s_one] == s_result1);
      BOOST_CHECK(what[c_one] == s_result1);
      BOOST_CHECK(what[cs_one] == s_result1);

      BOOST_CHECK(what.length(2) == 2);
      BOOST_CHECK(what.length(two) == 2);
      BOOST_CHECK(what.length(s_two) == 2);
      BOOST_CHECK(what.length(c_two) == 2);
      BOOST_CHECK(what.length(cs_two) == 2);
      BOOST_CHECK(what.position(2) == 5);
      BOOST_CHECK(what.position(two) == 5);
      BOOST_CHECK(what.position(s_two) == 5);
      BOOST_CHECK(what.position(c_two) == 5);
      BOOST_CHECK(what.position(cs_two) == 5);
      BOOST_CHECK(what.str(2) == s_result2);
      BOOST_CHECK(what.str(two) == s_result2);
      BOOST_CHECK(what.str(s_two) == s_result2);
      BOOST_CHECK(what.str(c_two) == s_result2);
      BOOST_CHECK(what.str(cs_two) == s_result2);
      BOOST_CHECK(what[2] == s_result2);
      BOOST_CHECK(what[two] == s_result2);
      BOOST_CHECK(what[s_two] == s_result2);
      BOOST_CHECK(what[c_two] == s_result2);
      BOOST_CHECK(what[cs_two] == s_result2);
   }
   else
   {
      BOOST_ERROR("Expected match not found");
   }
}
int main() {
    BOOST_TEST(type::instances == 0);
    try {
        boost::make_shared<type[]>(6);
        BOOST_ERROR("make_shared did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }

    BOOST_TEST(type::instances == 0);
    try {
        boost::make_shared<type[][2]>(3);
        BOOST_ERROR("make_shared did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }

    BOOST_TEST(type::instances == 0);
    try {
        boost::make_shared<type[6]>();
        BOOST_ERROR("make_shared did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }

    BOOST_TEST(type::instances == 0);
    try {
        boost::make_shared<type[3][2]>();
        BOOST_ERROR("make_shared did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }

    BOOST_TEST(type::instances == 0);
    try {
        boost::make_shared_noinit<type[]>(6);
        BOOST_ERROR("make_shared_noinit did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }

    BOOST_TEST(type::instances == 0);
    try {
        boost::make_shared_noinit<type[][2]>(3);
        BOOST_ERROR("make_shared_noinit did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }

    BOOST_TEST(type::instances == 0);
    try {
        boost::make_shared_noinit<type[6]>();
        BOOST_ERROR("make_shared_noinit did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }

    BOOST_TEST(type::instances == 0);
    try {
        boost::make_shared_noinit<type[3][2]>();
        BOOST_ERROR("make_shared_noinit did not throw");
    } catch (...) {
        BOOST_TEST(type::instances == 0);
    }

    return boost::report_errors();
}
Пример #25
0
inline void et_vq_null_error( const vq::null_error &e ) {
	std::ostringstream os;
	os<<"Unexpected NULL value in "<<e.file<<" at "<<e.line;
	BOOST_ERROR(os.str());
}
Пример #26
0
 void * operator new( std::size_t n )
 {
     // lack of this definition causes link errors on Comeau C++
     BOOST_ERROR( "private X::new called" );
     return ::operator new( n );
 }
Пример #27
0
inline void et_vq_db_error( const vq::db_error &e ) {
	std::ostringstream os;
	os<<"Database exception: "<<e.what<<" in "<<e.file<<" at "<<e.line;
	BOOST_ERROR(os.str());
}
Пример #28
0
 void operator delete( void * p )
 {
     // lack of this definition causes link errors on MSVC
     BOOST_ERROR( "private X::delete called" );
     ::operator delete( p );
 }
Пример #29
0
void testMacroD() {
    BOOST_ERROR("Failure of this function");
    double x = 0.0;
    BOOST_TEST(x != 0);
}
Пример #30
0
int main()
{
    BOOST_TEST( X::instances == 0 );

    {
        boost::shared_ptr<X> early_px;
        X* x = new X( 1, &early_px );
        BOOST_TEST( early_px.use_count() > 0 );
        BOOST_TEST( boost::get_deleter<X::deleter_type>(early_px) == 0 );
        boost::shared_ptr<X> px( x, &X::deleter2 );
        BOOST_TEST( early_px.use_count() == 2 && px.use_count() == 2 );
        BOOST_TEST(are_shared_owners(early_px, px));
        px.reset();
        BOOST_TEST( early_px.use_count() == 1 );
        BOOST_TEST( X::instances == 1 );
        // X::deleter_type *pd = boost::get_deleter<X::deleter_type>(early_px);
        // BOOST_TEST(pd && *pd == &X::deleter2 );
    }

    BOOST_TEST( X::instances == 0 );

    {
        boost::shared_ptr<X> early_px;
        X* x = new X( 1, &early_px );
        boost::weak_ptr<X> early_weak_px = early_px;
        early_px.reset();
        BOOST_TEST( !early_weak_px.expired() );
        boost::shared_ptr<X> px( x, &X::deleter2 );
        BOOST_TEST( px.use_count() == 1 );
        BOOST_TEST( X::instances == 1 );
        BOOST_TEST(are_shared_owners(early_weak_px.lock(), px));
        px.reset();
        BOOST_TEST( early_weak_px.expired() );
    }

    BOOST_TEST( X::instances == 0 );

    {
        boost::shared_ptr<X> early_px;
        X x( 1, &early_px );
        BOOST_TEST( early_px.use_count() > 0 );
        boost::shared_ptr<X> px( &x, &X::deleter );
        BOOST_TEST( early_px.use_count() == 2 && px.use_count() == 2 );
        early_px.reset();
        BOOST_TEST( px.use_count() == 1 );
        BOOST_TEST( X::instances == 1 );
        px.reset();
        try
        {
            x.shared_from_this();
            BOOST_ERROR("x did not throw bad_weak_ptr");
        }
        catch( const boost::bad_weak_ptr & )
        {}
    }

    BOOST_TEST( X::instances == 0 );

    {
        boost::weak_ptr<X> early_weak_px;
        {
            boost::shared_ptr<X> early_px;
            X x( 0, &early_px );
            early_weak_px = early_px;
            early_px.reset();
            BOOST_TEST( !early_weak_px.expired() );
            BOOST_TEST( X::instances == 1 );
        }
        BOOST_TEST( early_weak_px.expired() );
    }

    BOOST_TEST( X::instances == 0 );

    {
        boost::shared_ptr<Y> px(new Y());
        Y y(*px);
        px.reset();
        try
        {
            y.shared_from_this();
        }
        catch( const boost::bad_weak_ptr & )
        {
            BOOST_ERROR("y threw bad_weak_ptr");
        }
    }

    return boost::report_errors();
}