当前位置: 首页>>代码示例>>C++>>正文


C++ ASSERT_TRUE函数代码示例

本文整理汇总了C++中ASSERT_TRUE函数的典型用法代码示例。如果您正苦于以下问题:C++ ASSERT_TRUE函数的具体用法?C++ ASSERT_TRUE怎么用?C++ ASSERT_TRUE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ASSERT_TRUE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TEST

TEST(MAPPING, MAPPING5) {
    mkdir("tmp", 0700);
    TemporaryFile tmpfile("dbbuilder5", ".dat", "./tmp");

    FILE *filew = fopen(tmpfile.path(), "w");
    GenomeHash genomeHash;
    genomeHash.open(4, 4);
    genomeHash.insert("ATCG", 1);
    genomeHash.insert("GCTA", 2);
    genomeHash.save(filew);
    fprintf(filew, "1\tX\t1.0\n");
    fprintf(filew, "2\tY\t2.0\n");
    fclose(filew);

    {
        PFILE *pfile = pipedopen("./data/paired1.fastq", false);
        ASSERT_TRUE(pfile);
        cppfasta::FastqReader2 reader(pfile->file);

        std::map<std::string, int> result;
        std::map<std::string, double> fpkm;
        uint64_t num;
    
        ASSERT_TRUE(domapping(tmpfile.path(), &reader, &result, &fpkm, NULL, &num, 1, 1, false, false));
        ASSERT_EQ(4U, num);
        ASSERT_EQ(2, result["X"]);
        ASSERT_EQ(2, result["UNMAPPED"]);
        pipedclose(pfile);
    }

    {
        PFILE *pfile1 = pipedopen("./data/paired1.fastq", false);
        ASSERT_TRUE(pfile1);
        PFILE *pfile2 = pipedopen("./data/paired2.fastq", false);
        ASSERT_TRUE(pfile2);
        cppfasta::FastqReader2 reader(pfile1->file, pfile2->file);

        std::map<std::string, int> result;
        std::map<std::string, double> fpkm;
        uint64_t num;
    
        ASSERT_TRUE(domapping(tmpfile.path(), &reader, &result, &fpkm, NULL, &num, 1, 1, false, true));
        ASSERT_EQ(4U, num);
        ASSERT_EQ(3, result["X"]);
        ASSERT_EQ(1, result["UNMAPPED"]);

        pipedclose(pfile1);
        pipedclose(pfile2);
    }

    {
        PFILE *pfile = pipedopen("./data/paired-unified.fastq", false);
        ASSERT_TRUE(pfile);
        cppfasta::FastqReader2 reader(pfile->file);

        std::map<std::string, int> result;
        std::map<std::string, double> fpkm;
        uint64_t num;
    
        ASSERT_TRUE(domapping(tmpfile.path(), &reader, &result, &fpkm, NULL, &num, 1, 1, false, true));
        ASSERT_EQ(4U, num);
        ASSERT_EQ(3, result["X"]);
        ASSERT_EQ(1, result["UNMAPPED"]);

        pipedclose(pfile);
    }

    rmdir("tmp");
}
开发者ID:informationsea,项目名称:Matataki,代码行数:69,代码来源:test_mapping.cpp

示例2: TEST_F

/* Basic nominal test of a service.
 */
TEST_F(TestServiceFixture, test_service_nominal) {
  stop_memory_checking();
  rcl_ret_t ret;
  const rosidl_service_type_support_t * ts = ROSIDL_GET_TYPE_SUPPORT(
    example_interfaces, srv, AddTwoInts);
  const char * topic = "add_two_ints";

  rcl_service_t service = rcl_get_zero_initialized_service();
  rcl_service_options_t service_options = rcl_service_get_default_options();
  ret = rcl_service_init(&service, this->node_ptr, ts, topic, &service_options);
  ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();

  // Check that the service name matches what we assigned.
  EXPECT_EQ(strcmp(rcl_service_get_service_name(&service), topic), 0);
  auto service_exit = make_scope_exit([&service, this]() {
    stop_memory_checking();
    rcl_ret_t ret = rcl_service_fini(&service, this->node_ptr);
    EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
  });

  rcl_client_t client = rcl_get_zero_initialized_client();
  rcl_client_options_t client_options = rcl_client_get_default_options();
  ret = rcl_client_init(&client, this->node_ptr, ts, topic, &client_options);
  ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
  auto client_exit = make_scope_exit([&client, this]() {
    stop_memory_checking();
    rcl_ret_t ret = rcl_client_fini(&client, this->node_ptr);
    EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
  });


  // TODO(wjwwood): add logic to wait for the connection to be established
  //                use count_services busy wait mechanism
  //                until then we will sleep for a short period of time
  std::this_thread::sleep_for(std::chrono::milliseconds(1000));

  // Initialize a request.
  example_interfaces__srv__AddTwoInts_Request client_request;
  example_interfaces__srv__AddTwoInts_Request__init(&client_request);
  client_request.a = 1;
  client_request.b = 2;
  int64_t sequence_number;
  ret = rcl_send_request(&client, &client_request, &sequence_number);
  EXPECT_EQ(sequence_number, 1);
  example_interfaces__srv__AddTwoInts_Request__fini(&client_request);
  ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();

  bool success;
  wait_for_service_to_be_ready(&service, 10, 100, success);
  ASSERT_TRUE(success);

  // This scope simulates the service responding in a different context so that we can
  // test take_request/send_response in a single-threaded, deterministic execution.
  {
    // Initialize a response.
    example_interfaces__srv__AddTwoInts_Response service_response;
    example_interfaces__srv__AddTwoInts_Response__init(&service_response);
    auto msg_exit = make_scope_exit([&service_response]() {
      stop_memory_checking();
      example_interfaces__srv__AddTwoInts_Response__fini(&service_response);
    });

    // Initialize a separate instance of the request and take the pending request.
    example_interfaces__srv__AddTwoInts_Request service_request;
    example_interfaces__srv__AddTwoInts_Request__init(&service_request);
    rmw_request_id_t header;
    ret = rcl_take_request(&service, &header, &service_request);
    ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();

    EXPECT_EQ(1, service_request.a);
    EXPECT_EQ(2, service_request.b);
    // Simulate a response callback by summing the request and send the response..
    service_response.sum = service_request.a + service_request.b;
    ret = rcl_send_response(&service, &header, &service_response);
    ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
  }
  wait_for_service_to_be_ready(&service, 10, 100, success);

  // Initialize the response owned by the client and take the response.
  example_interfaces__srv__AddTwoInts_Response client_response;
  example_interfaces__srv__AddTwoInts_Response__init(&client_response);

  rmw_request_id_t header;
  ret = rcl_take_response(&client, &header, &client_response);
  ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
  EXPECT_EQ(client_response.sum, 3);
  EXPECT_EQ(header.sequence_number, 1);
}
开发者ID:erlerobot,项目名称:rcl,代码行数:90,代码来源:test_service.cpp

示例3: ASSERT_TRUE

sgraph& unity_sgraph::get_graph() const {
  ASSERT_TRUE(m_graph);
  return (*m_graph)();
};
开发者ID:GYGit,项目名称:SFrame,代码行数:4,代码来源:unity_sgraph.cpp

示例4: TEST_F

TEST_F(TestGet, test_get_one_row)
{
  int err = 0;
  CommonSchemaManagerWrapper schema_mgr;
  tbsys::CConfig config;
  bool ret_val = schema_mgr.parse_from_file("scan_schema.ini", config);
  ASSERT_TRUE(ret_val);
  ObUpsTableMgr& mgr = ObUpdateServerMain::get_instance()->get_update_server().get_table_mgr();
  err = mgr.init();
  ASSERT_EQ(0, err);
  err = mgr.set_schemas(schema_mgr);
  ASSERT_EQ(0, err);

  TestUpsTableMgrHelper test_helper(mgr);

  TableMgr& table_mgr = test_helper.get_table_mgr();
  table_mgr.sstable_scan_finished(10);

  TableItem* active_memtable_item = table_mgr.get_active_memtable();
  MemTable& active_memtable = active_memtable_item->get_memtable();

  // construct multi-row mutator
  static const int64_t ROW_NUM = 1;
  static const int64_t COL_NUM = 10;

  ObCellInfo cell_infos[ROW_NUM][COL_NUM];
  std::bitset<COL_NUM> check_flags[ROW_NUM];
  char row_key_strs[ROW_NUM][50];
  uint64_t table_id = 10;
  // init cell infos
  for (int64_t i = 0; i < ROW_NUM; ++i)
  {
    sprintf(row_key_strs[i], "row_key_%08ld", i);
    for (int64_t j = 0; j < COL_NUM; ++j)
    {
      cell_infos[i][j].table_id_ = table_id;
      cell_infos[i][j].row_key_ = make_rowkey(row_key_strs[i], &allocator_);

      cell_infos[i][j].column_id_ = j + 10;

      cell_infos[i][j].value_.set_int(1000 + i * COL_NUM + j);
    }
  }

  ObUpsMutator ups_mutator;
  ObMutator &mutator = ups_mutator.get_mutator();
  // add cell to array
  for (int64_t i = 0; i < ROW_NUM; ++i)
  {
    for (int64_t j = 0; j < COL_NUM; ++j)
    {
      ObMutatorCellInfo mutator_cell;
      mutator_cell.cell_info = cell_infos[i][j];
      mutator_cell.op_type.set_ext(ObActionFlag::OP_UPDATE);
      err = mutator.add_cell(mutator_cell);
      EXPECT_EQ(0, err);
    }
  }
  prepare_mutator(mutator);

  // write row to active memtable
  uint64_t trans_descriptor = 0;
  err = active_memtable.start_transaction(WRITE_TRANSACTION, trans_descriptor);
  ASSERT_EQ(0, err);
  err = active_memtable.start_mutation(trans_descriptor);
  ASSERT_EQ(0, err);
  err = active_memtable.set(trans_descriptor, ups_mutator);
  EXPECT_EQ(0, err);
  err = active_memtable.end_mutation(trans_descriptor, false);
  ASSERT_EQ(0, err);
  err = active_memtable.end_transaction(trans_descriptor, false);
  ASSERT_EQ(0, err);
  /*
  ObString text;
  text.assign("/tmp", strlen("/tmp"));
  active_memtable.dump2text(text);
  */

  for (int64_t i = 0; i < ROW_NUM; ++i)
  {
    ObScanner scanner;
    ObGetParam get_param;
    //get_param.set_timestamp(version);
    ObVersionRange version_range;
    //version_range.start_version_ = version;
    //version_range.end_version_ = version;
    version_range.start_version_ = 2;
    //version_range.end_version_ = 2;
    version_range.border_flag_.set_inclusive_start();
    //version_range.border_flag_.set_inclusive_end();
    version_range.border_flag_.set_max_value();
    get_param.set_version_range(version_range);
    for (int64_t j = 0; j < COL_NUM; ++j)
    {
      get_param.add_cell(cell_infos[i][j]);
    }

    int64_t count = 0;
    err = mgr.get(get_param, scanner, tbsys::CTimeUtil::getTime(), 2000000000 * 1000L * 1000L);
    EXPECT_EQ(0, err);
//.........这里部分代码省略.........
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:101,代码来源:test_get.cpp

示例5: TEST

TEST(ProcessorSet, empty) {
  ProcessorSet processor_set;
  ASSERT_TRUE(processor_set.empty());
  processor_set.set(0);
  ASSERT_FALSE(processor_set.empty());
}
开发者ID:respu,项目名称:yield,代码行数:6,代码来源:processor_set_test.cpp

示例6: TEST

TEST(RandoTest, nearestToZero)
{
  Rando rando;
  int a, b;
  ASSERT_TRUE( rando.nearestToZero(a,b));
}
开发者ID:gmabalot,项目名称:cpp-gtest,代码行数:6,代码来源:randoTest.cpp

示例7: TEST_F

TEST_F(MorphoGeneSerializationTest,isEqualAfterSerialization) {
    ASSERT_TRUE(morphoGene != morphoGene2);
    ASSERT_TRUE(morphoGene->equals(*morphoGene2));
}
开发者ID:netzz,项目名称:minemonics,代码行数:4,代码来源:Morphogene_test.cpp

示例8: WriteOut

	void WriteOut()
	{
		ASSERT_TRUE(writer.WriteOut("binaryTest.dat", false));

	}
开发者ID:Pctg-x8,项目名称:Altseed,代码行数:5,代码来源:asd.BinaryRederWriterTest.cpp

示例9: CTEST2

CTEST2(tube_stream, get_tube_manager)
{
    tube_manager *tm = tube_stream_manager_get_manager(data->sm);
    ASSERT_TRUE( (uintptr_t)tm == (uintptr_t)data->sm );
}
开发者ID:thomas-fossati,项目名称:SPUDlib,代码行数:5,代码来源:tube_stream_test.c

示例10: TearDown

	//}
	virtual void TearDown()
	{
		ASSERT_TRUE(s_pCmdParser != nullptr);
		s_pCmdParser->resetStatu();
	}
开发者ID:gse2015,项目名称:GitHubProject,代码行数:6,代码来源:UnitTest.cpp

示例11: consumer

void consumer(qi::atomic<long> &gSuccess, qi::Future<int> fut) {
  //wont block thread on error
  ASSERT_TRUE(fut.wait(1000));
  EXPECT_EQ(42, fut.value());
  ++gSuccess;
}
开发者ID:gnatali,项目名称:libqi,代码行数:6,代码来源:test_future.cpp

示例12: TEST

TEST(is_just_whitespaces, demo_case_true)
{
   ASSERT_TRUE(mzlib::is_just_whitespaces("\t\n \r\v\f"));
}
开发者ID:matejzavrsnik,项目名称:mzlib,代码行数:4,代码来源:is_just_whitespace.cpp

示例13: sleep

void NamenodeTest::test_namenode_server()
{
	for (int i = 1; i <= FLAGS_N; i++)
	{
		ThriftResult result;
		DatanodeHeartbeat hti;
		hti.endpoint.nodeid = i;
		mCluster.get_namenode_if()->datanode_heartbeat(result, hti);
	}

	sleep(2); //wait for heartbeat finish

	FileWriteToken token;
	mServer->get_write_token(token);

	int32_t blockid = token.blockid;

	ASSERT_TRUE(token.chunkids.size() == (size_t)FLAGS_N);

	std::set<int32_t> failed;
	int32_t failid = *token.chunkids.begin();
	LOG(ERROR) << "failed block id " << failid;
	failed.insert(failid);

	FileWriteToken fix_token;
	mServer->fix_write_token(fix_token, blockid, failed);

	ASSERT_TRUE(fix_token.chunkids[0] != token.chunkids[0]);

	for (int i = 1; i < FLAGS_N; i++) {
		ASSERT_TRUE(fix_token.chunkids[i] == token.chunkids[i]);
	}

	for (int i = 0; i < FLAGS_N; i++)
	{
		ThriftResult result;
		std::string data("hello world");
		int32_t chunkid = fix_token.chunkids[i];
		mCluster.get_datanode_if(NODE_ID(chunkid))->put_chunk(result, chunkid, data);
	}

	mServer->commit_write(blockid);

	FileReadToken read_token;
	mServer->get_read_token(read_token, blockid);

	for (int i = 0; i < FLAGS_N; i++) {
		ASSERT_TRUE(fix_token.chunkids[i] == read_token.chunkids[i]);
	}

	mServer->get_oplog_manager().uninit();
	mServer->get_oplog_manager().init();

	FileReadToken new_read;
	mServer->get_read_token(new_read, blockid);

	for (int i = 0; i < FLAGS_N; i++) {
		ASSERT_TRUE(fix_token.chunkids[i] == new_read.chunkids[i]);
	}

	mServer->delete_block(blockid);

	mServer->get_oplog_manager().uninit();
	mServer->get_oplog_manager().init();

	std::vector<int32_t> chunkids;
	mServer->get_block_manager().get_chunk_ids(blockid, chunkids, true);
	ASSERT_TRUE(chunkids.empty());
}
开发者ID:troywang,项目名称:ecfs,代码行数:69,代码来源:ecfs_namenode_test.cpp

示例14: TEST

// This test is disable because it is for generating test data.
TEST(libbacktrace, DISABLED_generate_offline_testdata) {
  // Create a thread to generate the needed stack and registers information.
  const size_t stack_size = 16 * 1024;
  void* stack = mmap(NULL, stack_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  ASSERT_NE(MAP_FAILED, stack);
  uintptr_t stack_addr = reinterpret_cast<uintptr_t>(stack);
  pthread_attr_t attr;
  ASSERT_EQ(0, pthread_attr_init(&attr));
  ASSERT_EQ(0, pthread_attr_setstack(&attr, reinterpret_cast<void*>(stack), stack_size));
  pthread_t thread;
  OfflineThreadArg arg;
  arg.exit_flag = 0;
  ASSERT_EQ(0, pthread_create(&thread, &attr, OfflineThreadFunc, &arg));
  // Wait for the offline thread to generate the stack and unw_context information.
  sleep(1);
  // Copy the stack information.
  std::vector<uint8_t> stack_data(reinterpret_cast<uint8_t*>(stack),
                                  reinterpret_cast<uint8_t*>(stack) + stack_size);
  arg.exit_flag = 1;
  ASSERT_EQ(0, pthread_join(thread, nullptr));
  ASSERT_EQ(0, munmap(stack, stack_size));

  std::unique_ptr<BacktraceMap> map(BacktraceMap::Create(getpid()));
  ASSERT_TRUE(map != nullptr);

  backtrace_stackinfo_t stack_info;
  stack_info.start = stack_addr;
  stack_info.end = stack_addr + stack_size;
  stack_info.data = stack_data.data();

  // Generate offline testdata.
  std::string testdata;
  // 1. Dump pid, tid
  testdata += android::base::StringPrintf("pid: %d tid: %d\n", getpid(), arg.tid);
  // 2. Dump maps
  for (auto it = map->begin(); it != map->end(); ++it) {
    testdata += android::base::StringPrintf(
        "map: start: %" PRIxPTR " end: %" PRIxPTR " offset: %" PRIxPTR " load_bias: %" PRIxPTR
        " flags: %d name: %s\n",
        it->start, it->end, it->offset, it->load_bias, it->flags, it->name.c_str());
  }
  // 3. Dump registers
  testdata += android::base::StringPrintf("registers: %zu ", sizeof(arg.unw_context));
  testdata += RawDataToHexString(&arg.unw_context, sizeof(arg.unw_context));
  testdata.push_back('\n');

  // 4. Dump stack
  testdata += android::base::StringPrintf(
      "stack: start: %" PRIx64 " end: %" PRIx64 " size: %zu ",
      stack_info.start, stack_info.end, stack_data.size());
  testdata += RawDataToHexString(stack_data.data(), stack_data.size());
  testdata.push_back('\n');

  // 5. Dump function symbols
  std::vector<FunctionSymbol> function_symbols = GetFunctionSymbols();
  for (const auto& symbol : function_symbols) {
    testdata += android::base::StringPrintf(
        "function: start: %" PRIxPTR " end: %" PRIxPTR" name: %s\n",
        symbol.start, symbol.end, symbol.name.c_str());
  }

  ASSERT_TRUE(android::base::WriteStringToFile(testdata, "offline_testdata"));
}
开发者ID:vicamo,项目名称:b2g_platform_system_core,代码行数:64,代码来源:backtrace_offline_test.cpp

示例15: main

int main(int argc, char** argv) {
  // Initialize control plain using mpi
  graphlab::mpi_tools::init(argc, argv);
  graphlab::distributed_control dc;
  dc_ptr = &dc;
  global_logger().set_log_level(LOG_INFO);

  // Parse command line options -----------------------------------------------
  graphlab::command_line_options clopts("./ldademo");
  std::string lda_edges;
  std::string lda_dictionary;

  bool USE_SYNC=false;

  // The dir of the link graph 
  clopts.attach_option("lda_edges", lda_edges, "The lda graph (edges). Required ");
  clopts.attach_option("lda_dictionary", lda_dictionary, "The lda word dictionary. Required ");
  clopts.attach_option("wordid_offset", lda::WORDID_OFFSET, "The starting id of the words in the lda input.");
  clopts.attach_option("ntopics", lda::NTOPICS, "Number of topics to use");
  clopts.attach_option("topklda", lda::TOPK, "Top k words in each topic for display");
  clopts.attach_option("force_lock", lda::FORCE_LOCK, "force locked words");
  clopts.attach_option("use_sync", USE_SYNC, "Use Synchronous LDA");

  if(!clopts.parse(argc, argv)) {
    dc.cout() << "Error in parsing command line arguments." << std::endl;
    return EXIT_FAILURE;
  }

  if(!clopts.is_set("lda_edges")) {
    std::cout << "LDA edge file not provided" << std::endl;
    clopts.print_description();
    return EXIT_FAILURE;
  }
  if(!clopts.is_set("lda_dictionary")) {
    std::cout << "LDA dictionary file not provided" << std::endl;
    clopts.print_description();
    return EXIT_FAILURE;
  }

  lda::INITIAL_NTOPICS = NTOPICS;

  // Build the lda (right) graph
  // The global lda_graph points to rgraph
  lda::graph_type ldagraph(dc);
  load_ldagraph(ldagraph, lda_edges, lda_dictionary);

  // Run lda -----------------------------------------------------------------
  launch_metric_server();

  graphlab::graphlab_options opts;
  std::string engine_type = "sync";
  if (!USE_SYNC) {
    opts.get_engine_args().set_option("factorized",true);
    engine_type = "async";
  }
  //opts2.get_engine_args().set_option("handler_intercept",true);
  graphlab::omni_engine<lda::cgs_lda_vertex_program> engine(dc, ldagraph, engine_type, opts);
  lda::initialize_global();
  { 
    const bool success =
        engine.add_vertex_aggregator<lda::topk_aggregator>
        ("topk", lda::topk_aggregator::map, lda::topk_aggregator::finalize) &&
        engine.aggregate_periodic("topk", 1);
    ASSERT_TRUE(success);
  }

  { // Add the Global counts aggregator
    const bool success =
        engine.add_vertex_aggregator<lda::factor_type>
        ("global_counts", 
         lda::global_counts_aggregator::map, 
         lda::global_counts_aggregator::finalize) &&
        engine.aggregate_periodic("global_counts", 1);
    ASSERT_TRUE(success);
  }
  fn_run_lda(engine);

// ------------FINALIZE------------------
// --------------------------------------
graphlab::stop_metric_server_on_eof();
graphlab::mpi_tools::finalize();

return EXIT_SUCCESS;
}
开发者ID:LiuJianan,项目名称:powerswitch,代码行数:84,代码来源:ldademo.cpp


注:本文中的ASSERT_TRUE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。