當前位置: 首頁>>代碼示例>>C++>>正文


C++ BOOST_CHECK_THROW函數代碼示例

本文整理匯總了C++中BOOST_CHECK_THROW函數的典型用法代碼示例。如果您正苦於以下問題:C++ BOOST_CHECK_THROW函數的具體用法?C++ BOOST_CHECK_THROW怎麽用?C++ BOOST_CHECK_THROW使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了BOOST_CHECK_THROW函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: try_lock_twice

void try_lock_twice()
{
    boost::fibers::mutex mtx;
    boost::unique_lock< boost::fibers::mutex > lk( mtx);

    BOOST_CHECK_THROW( lk.try_lock(), boost::lock_error);
}
開發者ID:anttirt,項目名稱:boost-fiber,代碼行數:7,代碼來源:test_unique_lock.cpp

示例2: testReadUntilFiltered

inline void testReadUntilFiltered(const char* format)
{
    TemporaryData data{format};

    brion::SpikeReport reportWrite(brion::URI(data.tmpFileName),
                                   brion::MODE_WRITE);
    reportWrite.write(data.spikes);
    reportWrite.close();

    brion::SpikeReport reportRead(brion::URI(data.tmpFileName),
                                  brion::GIDSet{22, 25});

    auto spikes = reportRead.readUntil(0.4).get();
    BOOST_CHECK_EQUAL(spikes.size(), 1);
    BOOST_CHECK(reportRead.getCurrentTime() >= 0.4f);
    BOOST_CHECK(spikes.rbegin()->first < 0.4);
    BOOST_CHECK_EQUAL(reportRead.getState(), brion::SpikeReport::State::ok);

    spikes = reportRead.readUntil(brion::UNDEFINED_TIMESTAMP).get();
    BOOST_CHECK_EQUAL(spikes.size(), 1);
    BOOST_CHECK_EQUAL(reportRead.getCurrentTime(), brion::UNDEFINED_TIMESTAMP);
    BOOST_CHECK_EQUAL(reportRead.getState(), brion::SpikeReport::State::ended);

    BOOST_CHECK_THROW(reportRead.read(reportRead.getCurrentTime()),
                      std::logic_error);
}
開發者ID:chevtche,項目名稱:Brion,代碼行數:26,代碼來源:spikeReport.cpp

示例3: BOOST_FIXTURE_TEST_CASE

BOOST_FIXTURE_TEST_CASE( test_suite_loop5, _2suites_4_cases )
{
    tc1->depends_on( s1 );

    master->p_default_status.value = ut::test_unit::RS_ENABLED;
    BOOST_CHECK_THROW( ut::framework::finalize_setup_phase( master->p_id ),
                       ut::framework::setup_error );
}
開發者ID:Franky666,項目名稱:programmiersprachen-raytracer,代碼行數:8,代碼來源:test_unit-order-test.cpp

示例4: testInvalidWrite

inline void testInvalidWrite(const char* format)
{
    TemporaryData data{format};
    brion::SpikeReport reportWrite(brion::URI(data.tmpFileName),
                                   brion::MODE_WRITE);
    reportWrite.write(data.spikes);

    BOOST_CHECK_THROW(reportWrite.write({{0.0, 0}}), std::logic_error);

    BOOST_CHECK_THROW(reportWrite.write(
                          {{10.0, 0}, {10.0, 1}, {11.0, 0}, {0.5, 1}}),
                      std::logic_error);

    brion::SpikeReport reportRead{brion::URI(data.tmpFileName),
                                  brion::MODE_READ};
    BOOST_CHECK_THROW(reportRead.write({{100.0, 0}}), std::runtime_error);
}
開發者ID:chevtche,項目名稱:Brion,代碼行數:17,代碼來源:spikeReport.cpp

示例5: operator

    void operator()() const
    {
        Mutex m;
        Lock lock(m);
        lock.unlock();

        BOOST_CHECK_THROW( lock.unlock(), boost::lock_error );
    }
開發者ID:engalex,項目名稱:ISA100.11a-Gateway,代碼行數:8,代碼來源:test_lock_concept.cpp

示例6: test_unlock_twice

void test_unlock_twice()
{
	boost::fibers::spin::mutex mtx;
	boost::unique_lock< boost::fibers::spin::mutex > lk( mtx);
	lk.unlock();

	BOOST_CHECK_THROW( lk.unlock(), boost::lock_error);
}
開發者ID:novator24,項目名稱:boost_task,代碼行數:8,代碼來源:test_spin_lock.cpp

示例7: BOOST_AUTO_TEST_CASE_TEMPLATE

BOOST_AUTO_TEST_CASE_TEMPLATE(members, T, float_types) {
	vmath::core::Matrix<T, 3> M;
	M[0] = vmath::core::Vector<T, 3>(static_cast<T>(1.0), static_cast<T>(2.0), static_cast<T>(3.0));
	M[1] = vmath::core::Vector<T, 3>(static_cast<T>(4.0), static_cast<T>(5.0), static_cast<T>(6.0));
	M[2] = vmath::core::Vector<T, 3>(static_cast<T>(7.0), static_cast<T>(8.0), static_cast<T>(9.0));
	BOOST_CHECK_CLOSE(M[0][0], static_cast<T>(1.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[0][1], static_cast<T>(2.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[0][2], static_cast<T>(3.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[1][0], static_cast<T>(4.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[1][1], static_cast<T>(5.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[1][2], static_cast<T>(6.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[2][0], static_cast<T>(7.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[2][1], static_cast<T>(8.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[2][2], static_cast<T>(9.0), 1e-4f);
	// invalid index
	BOOST_CHECK_THROW(M[3], std::out_of_range);
	BOOST_CHECK_THROW((M[3] = vmath::core::Vector<T, 3>()), std::out_of_range);
}
開發者ID:kernan,項目名稱:vmath,代碼行數:18,代碼來源:matrix3x3.cpp

示例8: const_test_f

void const_test_f( json::value const & value )
{
   BOOST_CHECK(value.has_key("cafe"));

   BOOST_CHECK_THROW(value["sam"], std::out_of_range);

   BOOST_CHECK_EQUAL(value["cafe"], "open");
   BOOST_CHECK_EQUAL(value["bar"][2], 1234.5);
}
開發者ID:AbdelghaniDr,項目名稱:json_spirit,代碼行數:9,代碼來源:value_object.cpp

示例9: BOOST_CHECK_THROW

 void C2STestSocketListener::runTest()
 {
   C2STestSocketListener testSocketListener;
   BOOST_CHECK_THROW( testSocketListener.sendTestMessageThroughSocket() , C2SSocketException );
   testSocketListener.startSocketListener();
   testSocketListener.sendTestMessageThroughSocket();
   testSocketListener.sendTestMessageThroughSocket();
   testSocketListener.shutdownSocketListener();
 }
開發者ID:AmiGanguli,項目名稱:C2Serve,代碼行數:9,代碼來源:C2STestSocketListener.cpp

示例10: WESNOTH_PARAMETERIZED_TEST_CASE

WESNOTH_PARAMETERIZED_TEST_CASE( test_multi_sendfile, sendfile_param, sendfile_sizes, size )
{
	auto_resetter<std::string> path("", game_config::path);
	network::set_raw_data_only();
	std::string file = create_random_sendfile(size.size_);
	network_worker_pool::set_use_system_sendfile(size.system_);

	network::connection cl_client1, se_client1;
	network::connection cl_client2, se_client2;
	network::connection cl_client3, se_client3;

	BOOST_CHECK_MESSAGE((cl_client1 = network::connect(LOCALHOST, TEST_PORT)) > 0, "Can't connect to server!");
	BOOST_CHECK_MESSAGE((se_client1 = network::accept_connection()) > 0, "Coulnd't accept new connection");
	BOOST_CHECK_MESSAGE((cl_client2 = network::connect(LOCALHOST, TEST_PORT)) > 0, "Can't connect to server!");
	BOOST_CHECK_MESSAGE((se_client2 = network::accept_connection()) > 0, "Coulnd't accept new connection");
	BOOST_CHECK_MESSAGE((cl_client3 = network::connect(LOCALHOST, TEST_PORT)) > 0, "Can't connect to server!");
	BOOST_CHECK_MESSAGE((se_client3 = network::accept_connection()) > 0, "Coulnd't accept new connection");

	network::send_file(file, cl_client1);
	network::send_file(file, cl_client2);
	network::send_file(file, cl_client3);

	std::vector<char> data;

	BOOST_CHECK_PREDICATE(test_utils::one_of<network::connection> , (receive(data,500))(3)(se_client1)(se_client2)(se_client3));
	BOOST_CHECK_EQUAL(data.size(), static_cast<size_t>(file_size(file)));
	BOOST_CHECK_PREDICATE(test_utils::one_of<network::connection> , (receive(data,500))(3)(se_client1)(se_client2)(se_client3));
	BOOST_CHECK_EQUAL(data.size(), static_cast<size_t>(file_size(file)));
	BOOST_CHECK_PREDICATE(test_utils::one_of<network::connection> , (receive(data,500))(3)(se_client1)(se_client2)(se_client3));

	BOOST_CHECK_EQUAL(data.size(), static_cast<size_t>(file_size(file)));

	network::disconnect(cl_client1);
	network::disconnect(cl_client2);
	network::disconnect(cl_client3);

	BOOST_CHECK_THROW(receive(data),network::error);
	BOOST_CHECK_THROW(receive(data),network::error);
	BOOST_CHECK_THROW(receive(data),network::error);

	delete_random_sendfile(file);
}
開發者ID:RushilPatel,項目名稱:BattleForWesnoth,代碼行數:42,代碼來源:test_network_worker.cpp

示例11: All

 static void All()
 {
     static const String FieldName = STR( "coin" );
     static const std::pair< uint32_t, uint32_t > FieldPrecision = std::make_pair( 10, 5 );
     DatabaseValuedObjectInfosSPtr infos;
     BOOST_CHECK_NO_THROW( infos = std::make_shared< CDatabaseValuedObjectInfos >( FieldName ) );
     BOOST_CHECK( infos );
     BOOST_CHECK( infos->GetName() == FieldName );
     BOOST_CHECK( infos->GetType() == EFieldType_NULL );
     BOOST_CHECK_THROW( infos->SetType( FieldType ), CDatabaseException );
     BOOST_CHECK_THROW( infos->SetType( FieldType, FieldPrecision.first ), CDatabaseException );
     BOOST_CHECK_NO_THROW( infos->SetType( FieldType, FieldPrecision ) );
     BOOST_CHECK( infos->GetType() == FieldType );
     BOOST_CHECK( infos->GetPrecision() == FieldPrecision );
     BOOST_CHECK_THROW( infos = std::make_shared< CDatabaseValuedObjectInfos >( FieldName, FieldType ), CDatabaseException );
     BOOST_CHECK_THROW( infos = std::make_shared< CDatabaseValuedObjectInfos >( FieldName, FieldType, FieldPrecision.first ), CDatabaseException );
     BOOST_CHECK_NO_THROW( infos = std::make_shared< CDatabaseValuedObjectInfos >( FieldName, FieldType, FieldPrecision ) );
     BOOST_CHECK( infos->GetType() == FieldType );
     BOOST_CHECK( infos->GetPrecision() == FieldPrecision );
 }
開發者ID:DragonJoker,項目名稱:DatabaseConnector,代碼行數:20,代碼來源:DatabaseValuedObjectInfosTest.cpp

示例12: checkValidity

 void
 checkValidity(std::string parameters, bool isCorrect)
 {
   Name strategyName(Name(AsfStrategy::getStrategyName()).append(parameters));
   if (isCorrect) {
     BOOST_CHECK_NO_THROW(make_unique<AsfStrategy>(forwarder, strategyName));
   }
   else {
     BOOST_CHECK_THROW(make_unique<AsfStrategy>(forwarder, strategyName), std::invalid_argument);
   }
 }
開發者ID:named-data,項目名稱:NFD,代碼行數:11,代碼來源:asf-strategy.t.cpp

示例13: RunCreate

static void RunCreate(const int64_t& num)
{
    CheckCreateInt(num);
    CScriptNum scriptnum(num);
    if (scriptnum.getvch().size() <= CScriptNum::nMaxNumSize)
        CheckCreateVch(num);
    else
    {
        BOOST_CHECK_THROW (CheckCreateVch(num), scriptnum_error);
    }
}
開發者ID:facilecoin,項目名稱:facilecoin-core,代碼行數:11,代碼來源:scriptnum_tests.cpp

示例14: BOOST_FIXTURE_TEST_CASE

BOOST_FIXTURE_TEST_CASE(FullName, DataIdentityFixture)
{
  // Encoding pipeline

  ndn::Data d(ndn::Name("/local/ndn/prefix"));
  d.setContentType(tlv::ContentType_Blob);
  d.setFreshnessPeriod(time::seconds(10));

  d.setContent(Content1, sizeof(Content1));

  BOOST_CHECK_THROW(d.getFullName(), Data::Error);

  keyChain.sign(d, security::SigningInfo(security::SigningInfo::SIGNER_TYPE_CERT, certName));

  Name fullName;
  BOOST_REQUIRE_NO_THROW(fullName = d.getFullName());

  BOOST_CHECK_EQUAL(d.getName().hasWire(), true);
  BOOST_CHECK_EQUAL(fullName.hasWire(), false);

  // check if name was properly cached
  BOOST_CHECK_EQUAL(fullName.get(-1).value(), d.getFullName().get(-1).value());

  // check FullName content
  BOOST_REQUIRE_EQUAL(d.getName().size() + 1, fullName.size());
  BOOST_CHECK_EQUAL_COLLECTIONS(d.getName().begin(), d.getName().end(),
                                fullName.begin(), fullName.end() - 1);
  BOOST_CHECK_EQUAL(fullName.get(-1).value_size(), 32);

  // FullName should be reset after the next line
  d.setFreshnessPeriod(time::seconds(100));
  BOOST_CHECK_THROW(d.getFullName(), Data::Error);

  // Decoding pipeline
  d.wireDecode(Block(Data1, sizeof(Data1)));
  BOOST_REQUIRE_NO_THROW(fullName = d.getFullName());

  BOOST_CHECK_EQUAL(fullName.toUri(),
    "/local/ndn/prefix/"
    "sha256digest=28bad4b5275bd392dbb670c75cf0b66f13f7942b21e80f55c0e86b374753a548");
}
開發者ID:2nd-ndn-hackathon,項目名稱:ndn-cxx-logging,代碼行數:41,代碼來源:data.t.cpp

示例15: ExpectActionFailure

		void ExpectActionFailure(Fn && action)
		{
			CCar clone(car);
			BOOST_CHECK_THROW(action(), std::exception);
			BOOST_REQUIRE_EQUAL(clone.IsEngineOn(), car.IsEngineOn());
			if (clone.IsEngineOn())
			{
				BOOST_CHECK(clone.GetDirection() == car.GetDirection());
				BOOST_CHECK(clone.GetGear() == car.GetGear());
				BOOST_CHECK(clone.GetSpeed() == car.GetSpeed());
			}
		}
開發者ID:dervesp,項目名稱:cpp_lab_3,代碼行數:12,代碼來源:CarTests.cpp


注:本文中的BOOST_CHECK_THROW函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。