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


C++ BOOST_REQUIRE函數代碼示例

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


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

示例1: BOOST_FIXTURE_TEST_CASE

BOOST_FIXTURE_TEST_CASE(OnConnectFailed, AuthorizedCommandFixture<FaceFixture>)
{
  ControlParameters parameters;
  parameters.setUri("tcp://127.0.0.1");

  Block encodedParameters(parameters.wireEncode());

  Name commandName("/localhost/nfd/faces");
  commandName.append("create");
  commandName.append(encodedParameters);

  shared_ptr<Interest> command(make_shared<Interest>(commandName));
  generateCommand(*command);

  getFace()->onReceiveData += [this, command] (const Data& response) {
    this->validateControlResponse(response, command->getName(), 408, "unit-test-reason");
  };

  onConnectFailed(command->getName(), "unit-test-reason");

  BOOST_REQUIRE(didCallbackFire());
  BOOST_CHECK_EQUAL(didReceiveNotication(), false);
}
開發者ID:WeiqiJust,項目名稱:NDN-total,代碼行數:23,代碼來源:face-manager.cpp

示例2: get_argument

static std::string get_argument(const std::string &word) 
{ 
    std::vector<std::string> args; 
    args.push_back("helpers"); 
    args.push_back("echo-quoted"); 
    args.push_back(word); 

    bp::context ctx; 
    ctx.stdout_behavior = bp::capture_stream(); 
    ctx.environment = bp::self::get_environment(); 

    bp::child c = bp::launch(get_helpers_path(), args, ctx); 
    bp::pistream &is = c.get_stdout(); 

    std::string result; 
    portable_getline(is, result); 

    const bp::status s = c.wait(); 
    BOOST_REQUIRE(s.exited()); 
    BOOST_CHECK_EQUAL(s.exit_status(), EXIT_SUCCESS); 

    return result; 
} 
開發者ID:CovenantEyes,項目名稱:boost-process,代碼行數:23,代碼來源:arguments_test.cpp

示例3: test_main

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;
}
開發者ID:TheRyaz,項目名稱:c_reading,代碼行數:23,代碼來源:minimal_test.cpp

示例4: switch

su3vec* SpinorStaggeredfieldCreator::createSpinorfield(SpinorFillType fillTypeIn)
{
    su3vec* in;
    in = new su3vec[numberOfElements];
    switch (fillTypeIn) {
        case SpinorFillType::zero:
            fill_with_zero(in, numberOfElements);
            break;
        case SpinorFillType::one:
            fill_with_one(in, numberOfElements);
            break;
        case SpinorFillType::ascendingReal:
            fill_with_ascending(in, numberOfElements);
            break;
        case SpinorFillType::ascendingComplex:
            fillWithAscendingComplex(in, numberOfElements);
            break;
        default:
            logger.fatal() << "do not know fill type!";
    }
    BOOST_REQUIRE(in);
    return in;
}
開發者ID:CL2QCD,項目名稱:cl2qcd,代碼行數:23,代碼來源:SpinorStaggeredTester.cpp

示例5: test_make_backend_readonly

static void test_make_backend_readonly(session &sess)
{
	server_node &node = global_data->nodes.back();
	const key id = std::string("read_only_key");
	const std::string data = "read_only_data";

	ELLIPTICS_REQUIRE(async_readonly_result, sess.make_readonly(node.remote(), 4));

	backend_status_result_entry result = async_readonly_result.get_one();
	BOOST_REQUIRE(result.is_valid());
	BOOST_REQUIRE_EQUAL(result.count(), 1);

	dnet_backend_status *status = result.backend(0);
	BOOST_REQUIRE_EQUAL(status->backend_id, 4);
	BOOST_REQUIRE_EQUAL(status->read_only, true);

	session new_sess = sess.clone();
	new_sess.set_direct_id(node.remote(), 4);

	ELLIPTICS_REQUIRE_ERROR(write_result, new_sess.write_data(id, data, 0), -EROFS);

	ELLIPTICS_REQUIRE_ERROR(second_async_readonly_result, sess.make_readonly(node.remote(), 4), -EALREADY);
}
開發者ID:ProgDevel,項目名稱:elliptics,代碼行數:23,代碼來源:backends_test.cpp

示例6: test2

int test2(){
    const char * testfile = boost::archive::tmpnam(NULL);
    BOOST_REQUIRE(NULL != testfile);

    J *j1 = new J;
    j1->j = j1;
    J *j2 = reinterpret_cast<J *>(0xBAADF00D);
    {
        test_ostream os(testfile, TEST_STREAM_FLAGS);
        test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
        oa << BOOST_SERIALIZATION_NVP(j1);
    }
    {
        // try to read the archive
        test_istream is(testfile, TEST_STREAM_FLAGS);
        test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
        ia >> BOOST_SERIALIZATION_NVP(j2);
    }
    BOOST_CHECK(*j1 == *j2);
    BOOST_CHECK(j2 == j2->j);
    std::remove(testfile);
    return EXIT_SUCCESS;
}
開發者ID:LancelotGHX,項目名稱:Simula,代碼行數:23,代碼來源:test_cyclic_ptrs.cpp

示例7: test_multimap

void
test_multimap(){
    const char * testfile = boost::archive::tmpnam(NULL);
    BOOST_REQUIRE(NULL != testfile);

    BOOST_MESSAGE("multimap");
    std::multimap<random_key, A> amultimap;
    amultimap.insert(std::make_pair(random_key(), A()));
    amultimap.insert(std::make_pair(random_key(), A()));
    {   
        test_ostream os(testfile, TEST_STREAM_FLAGS);
        test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
        oa << boost::serialization::make_nvp("amultimap", amultimap);
    }
    std::multimap<random_key, A> amultimap1;
    {
        test_istream is(testfile, TEST_STREAM_FLAGS);
        test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
        ia >> boost::serialization::make_nvp("amultimap", amultimap1);
    }
    BOOST_CHECK(amultimap == amultimap1);
    std::remove(testfile);
}
開發者ID:0xDEC0DE8,項目名稱:mcsema,代碼行數:23,代碼來源:test_map.cpp

示例8: unit_test_decode_yenc_bug_32

// unit test case for Issue #32
void unit_test_decode_yenc_bug_32()
{
    delete_file("02252012paul-10w(WallPaperByPaul)[1280X800].jpg");

    nf::download download({"alt.binaries.wallpaper"}, {"1", "2"}, "", "test");
    nf::session session;
    session.on_send = [&](const std::string&) {};

    auto cmdlist = download.create_commands();

    cmdlist->submit_data_commands(session);
    cmdlist->receive_data_buffer(read_file_buffer("test_data/wallpaper.jpg-002.yenc"));
    cmdlist->receive_data_buffer(read_file_buffer("test_data/wallpaper.jpg-001.yenc"));

    std::vector<std::unique_ptr<nf::action>> actions1;
    std::vector<std::unique_ptr<nf::action>> actions2;
    download.complete(*cmdlist, actions1);

    while (!actions1.empty())
    {
        for (auto& it : actions1)
        {
            it->perform();
            download.complete(*it, actions2);
        }
        actions1 = std::move(actions2);
        actions2 = std::vector<std::unique_ptr<nf::action>>();
    }

    download.commit();

    const auto& jpg = read_file_contents("02252012paul-10w(WallPaperByPaul)[1280X800].jpg");
    const auto& ref = read_file_contents("test_data/wallpaper.jpg");
    BOOST_REQUIRE(jpg == ref);

    delete_file("02252012paul-10w(WallPaperByPaul)[1280X800].jpg");
}
開發者ID:ensisoft,項目名稱:newsflash-plus,代碼行數:38,代碼來源:unit_test_download.cpp

示例9: FC_CAPTURE_AND_RETHROW

void database_fixture::set_price_feed( const price& new_price )
{
   try
   {
      for ( int i = 1; i < 8; i++ )
      {
         feed_publish_operation op;
         op.publisher = STEEMIT_INIT_MINER_NAME + fc::to_string( i );
         op.exchange_rate = new_price;
         trx.operations.push_back( op );
         trx.set_expiration( db.head_block_time() + STEEMIT_MAX_TIME_UNTIL_EXPIRATION );
         db.push_transaction( trx, ~0 );
         trx.operations.clear();
      }
   } FC_CAPTURE_AND_RETHROW( (new_price) )

   generate_blocks( STEEMIT_BLOCKS_PER_HOUR );
   BOOST_REQUIRE(
#ifdef IS_TEST_NET
      !db.skip_price_feed_limit_check ||
#endif
      db.get(feed_history_id_type()).current_median_history == new_price
   );
}
開發者ID:mingyukim123,項目名稱:steem,代碼行數:24,代碼來源:database_fixture.cpp

示例10: BOOST_REQUIRE

		/// \brief Use the specified DSSP file to check the hbond calculations for the specified PDB file
		///
		/// \todo Remove the arg_warn_only_on_diff argument if dssp_ignores_valid_residue_1 is resolved
		inline void dssp_hbond_calc_test_suite_fixture::use_dssp_file_to_check_hbonds_calcs(const path &arg_dssp_file,        ///< The DSSP file to compare against
		                                                                                    const path &arg_pdb_file,         ///< The PDB file to check
		                                                                                    const bool &arg_warn_only_on_diff ///< Whether to only warn on differences
		                                                                                    ) {
			BOOST_REQUIRE( exists( arg_pdb_file ) );
			// const auto read_dssp_start_time = high_resolution_clock::now();
			const auto dssp_hbonds = parse_dssp_for_calc_testing( arg_dssp_file );
			// const auto read_dssp_stop_time  = high_resolution_clock::now();

			if ( ! dssp_hbonds.empty() ) {
				// const auto read_pdb_start_time = high_resolution_clock::now();
				const auto parsed_pdb          = read_pdb_file( arg_pdb_file );
				// const auto read_pdb_stop_time  = high_resolution_clock::now();

				protein_from_dssp_and_pdb( read_dssp_file( arg_dssp_file ), parsed_pdb, dssp_skip_policy::DONT_SKIP__BREAK_ANGLES );

				// const auto calc_start_time = high_resolution_clock::now();
				const auto bifur_hbonds = dssp_hbond_calc::calc_bifur_hbonds_of_pdb__recalc_backbone_residues(
					parsed_pdb
				);
				// const auto calc_stop_time  = high_resolution_clock::now();

				// std::cerr << "Read DSSP   : " << durn_to_seconds_string ( read_dssp_stop_time - read_dssp_start_time ) << "\n";
				// std::cerr << "Read PDB    : " << durn_to_seconds_string ( read_pdb_stop_time  - read_pdb_start_time  ) << "\n";
				// std::cerr << "Calc hbonds : " << durn_to_seconds_string ( calc_stop_time      - calc_start_time      ) << "\n";

				// BOOST_TEST_INFO() isn't present in Boost > 1.58.0
				// BOOST_TEST_INFO  ( "Checking DSSP file \"" + arg_dssp_file.string() + "\"" );
				if ( arg_warn_only_on_diff ) {
					BOOST_WARN_EQUAL ( difference_string( dssp_hbonds, bifur_hbonds ), none );
				}
				else {
					BOOST_CHECK_EQUAL( difference_string( dssp_hbonds, bifur_hbonds ), none );
				}
			}
		}
開發者ID:UCLOrengoGroup,項目名稱:cath-tools,代碼行數:39,代碼來源:dssp_hbond_calc_test.cpp

示例11: setup

  /**
   * Create the Cassandra cluster, initialize the cpp-driver cluster, and create
   * the connection to the cluster.
   *
   * @param is_ssl True if SSL should be enabled on Cassandra cluster; false
   *               otherwise (default: true)
   * @param is_client_authentication True if client authentication should be
   *                                 enabled on Cassandra cluster; false otherwise
   *                                 (default: false)
   * @param is_failure True if test is supposed to fail; false otherwise
   *                   (default: false)
   * @param nodes Number of nodes for the cluster (default: 1)
   */
  void setup(bool is_ssl = true, bool is_client_authentication = false, bool is_failure = false, unsigned int nodes = 1) {
    //Create a n-node cluster
    ccm_->create_cluster(nodes, 0, false, is_ssl, is_client_authentication);
    ccm_->start_cluster();

    //Initialize the cpp-driver
    cluster_ = cass_cluster_new();
    test_utils::initialize_contact_points(cluster_, ccm_->get_ip_prefix(), nodes);
    cass_cluster_set_connect_timeout(cluster_, 10000);
    cass_cluster_set_request_timeout(cluster_, 10000);
    cass_cluster_set_num_threads_io(cluster_, 1);
    cass_cluster_set_core_connections_per_host(cluster_, 2);
    cass_cluster_set_max_connections_per_host(cluster_, 4);
    cass_cluster_set_ssl(cluster_, ssl_);

    //Establish the connection (if ssl)
    session_ = cass_session_new();
    connect_future_ = cass_session_connect(session_, cluster_);
    if (!is_failure) {
      test_utils::wait_and_check_error(connect_future_);
    } else {
      BOOST_REQUIRE(!cass_future_wait_timed(connect_future_, 2000)); //Ensure the wait is long enough for slow machines
    }
  }
開發者ID:cybergarage,項目名稱:cpp-driver,代碼行數:37,代碼來源:test_ssl.cpp

示例12: BOOST_FIXTURE_TEST_CASE_TEMPLATE

BOOST_FIXTURE_TEST_CASE_TEMPLATE(InsertReadDelete, T, CommonDatasets, Fixture<T>)
{
  BOOST_TEST_CHECKPOINT(T::getName());

  std::vector<Name> names;

  // Insert
  for (auto i = this->data.begin();
       i != this->data.end(); ++i) {
    Name name = Name();
    this->handle->insert(**i);
    name = (*i)->getFullName();
    this->nameToDataMap.insert(std::make_pair(name, *i));
    names.push_back(name);
  }
  BOOST_CHECK_EQUAL(this->handle->size(), static_cast<int64_t>(this->data.size()));

  std::mt19937 rng{std::random_device{}()};
  std::shuffle(names.begin(), names.end(), rng);

  // Read (all items should exist)
  for (auto i = names.begin(); i != names.end(); ++i) {
    std::shared_ptr<Data> retrievedData = this->handle->read(*i);

    BOOST_REQUIRE(this->nameToDataMap.count(*i) > 0);
    BOOST_CHECK_EQUAL(*this->nameToDataMap[*i], *retrievedData);
  }
  BOOST_CHECK_EQUAL(this->handle->size(), static_cast<int64_t>(this->data.size()));

  // Delete
  for (auto i = names.begin(); i != names.end(); ++i) {
    BOOST_CHECK_EQUAL(this->handle->erase(*i), true);
  }

  BOOST_CHECK_EQUAL(this->handle->size(), 0);
}
開發者ID:named-data,項目名稱:repo-ng,代碼行數:36,代碼來源:sqlite-handle.cpp

示例13: BOOST_FIXTURE_TEST_CASE_TEMPLATE

BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhopNackToNonLocal,
                                 T, Tests, StrategyScopeControlFixture<typename T::Strategy>)
{
  fib::Entry* fibEntry = this->fib.insert("/localhop/A").first;
  fibEntry->addOrUpdateNextHop(*this->localFace4, 0, 10);
  fibEntry->addOrUpdateNextHop(*this->nonLocalFace2, 0, 20);

  auto interest = makeInterest("/localhop/A/1", 1377);
  shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
  pitEntry->insertOrUpdateInRecord(*this->nonLocalFace1, 0, *interest);
  lp::Nack nack = makeNack(*interest, lp::NackReason::NO_ROUTE);
  pitEntry->insertOrUpdateOutRecord(*this->localFace4, 0, *interest)->setIncomingNack(nack);

  BOOST_REQUIRE(this->strategy.waitForAction(
    [&] { this->strategy.afterReceiveNack(FaceEndpoint(*this->localFace4, 0), nack, pitEntry); },
    this->limitedIo, T::canProcessNack()));

  BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.size(), 0);
  BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), 0);
  if (T::canProcessNack()) {
    BOOST_REQUIRE_EQUAL(this->strategy.sendNackHistory.size(), 1);
    BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.back().header.getReason(), lp::NackReason::NO_ROUTE);
  }
}
開發者ID:named-data,項目名稱:NFD,代碼行數:24,代碼來源:strategy-scope-control.t.cpp

示例14: BOOST_FIXTURE_TEST_CASE

BOOST_FIXTURE_TEST_CASE(UnauthorizedCommand,
                        UnauthorizedCommandFixture<StrategyChoiceManagerFixture>)
{
  ControlParameters parameters;
  parameters.setName("/test");
  parameters.setStrategy("/localhost/nfd/strategy/best-route");

  Block encodedParameters(parameters.wireEncode());

  Name commandName("/localhost/nfd/strategy-choice");
  commandName.append("set");
  commandName.append(encodedParameters);

  shared_ptr<Interest> command(make_shared<Interest>(commandName));
  generateCommand(*command);

  getFace()->onReceiveData +=
    bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
         command->getName(), 403, "Unauthorized command");

  getManager().onStrategyChoiceRequest(*command);

  BOOST_REQUIRE(didCallbackFire());
}
開發者ID:PhilipsIII,項目名稱:NFD,代碼行數:24,代碼來源:strategy-choice-manager.cpp

示例15: test_vector

int test_vector(T)
{
    const char * testfile = boost::archive::tmpnam(NULL);
    BOOST_REQUIRE(NULL != testfile);

    // test array of objects
    std::vector<T> avector;
    avector.push_back(T());
    avector.push_back(T());
    {   
        test_ostream os(testfile, TEST_STREAM_FLAGS);
        test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
        oa << boost::serialization::make_nvp("avector", avector);
    }
    std::vector<T> avector1;
    {
        test_istream is(testfile, TEST_STREAM_FLAGS);
        test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
        ia >> boost::serialization::make_nvp("avector", avector1);
    }
    BOOST_CHECK(avector == avector1);
    std::remove(testfile);
    return EXIT_SUCCESS;
}
開發者ID:0xDEC0DE8,項目名稱:mcsema,代碼行數:24,代碼來源:performance_vector.cpp


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