• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ASSERT_GE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testSorting

void testSorting(std::vector<uint64_t> values, uint64_t memSize) {
  char inFileName[] = "unsortedXXXXXX";
  char outFileName[] = "sortedXXXXXX";
  //create temporary input and output files
  int fdIn = mkstemp(inFileName);
  ASSERT_GE(fdIn, 0) << "unable to create input file: " << strerror(errno);
  int fdOut = mkstemp(outFileName);
  ASSERT_GE(fdOut, 0) << "unable to create output file: " << strerror(errno);

  //store the input numbers into the input file
  uint64_t bytesWritten = 0;
  uint64_t bytesToBeWritten = values.size()*sizeof(uint64_t);
  while(bytesWritten < bytesToBeWritten) {
    int pwriteRet = pwrite(fdIn, &values[0], bytesToBeWritten - bytesWritten, bytesWritten);
    ASSERT_GE(pwriteRet, 0) << "unable to write values to input file: " << strerror(errno);
    bytesWritten += pwriteRet;
  }

  //sort the values
  dbImpl::externalSort(fdIn, values.size(), fdOut, memSize);

  //check the file size of the output file
  struct stat outStat;
  ASSERT_EQ(0, fstat(fdOut, &outStat)) << strerror(errno);
  EXPECT_EQ(values.size()*sizeof(uint64_t), outStat.st_size);

  //read back the results
  std::unique_ptr<uint64_t[]> results(new uint64_t[values.size()]);
  uint64_t bytesRead = 0;
  uint64_t bytesToBeRead = values.size()*sizeof(uint64_t);
  while(bytesRead < bytesToBeRead) {
    int preadRet = pread(fdOut, &results[0], bytesToBeRead - bytesRead, bytesRead);
    ASSERT_GE(preadRet, 0) << "unable to read values from output file: " << strerror(errno);
    bytesRead += preadRet;
  }
  //they should be sorted now...
  ASSERT_TRUE(std::is_sorted(&results[0], &results[values.size()]));

  //close both file descriptors
  //since they were created using O_TMPFILE, the files will be
  //deleted automatically
  ASSERT_EQ(0, close(fdOut)) << strerror(errno);
  ASSERT_EQ(0, close(fdIn)) << strerror(errno);
  //unlink the files
  ASSERT_EQ(0, unlink(inFileName)) << strerror(errno);
  ASSERT_EQ(0, unlink(outFileName)) << strerror(errno);
}
开发者ID:vogelsgesang,项目名称:dbimpl,代码行数:47,代码来源:externalSortTest.cpp


示例2: ASSERT_GE

	void bar_widget::set_value(const std::string& key, const variant& value)
	{
		if(key == "segments") {
			segments_ = value.as_int();
			ASSERT_GE(segments_, 0);
			init();
		} else if(key == "segment_length") {
			segment_length_ = value.as_int();
			ASSERT_GT(segment_length_, 0);
			init();
		} else if(key == "tick_width") {
			tick_width_ = value.as_int();
			ASSERT_GT(tick_width_, 0);
			init();
		} else if(key == "scale") {
			scale_ = value.as_decimal().as_float();
			ASSERT_GT(scale_, 0.0f);
			init();
		} else if(key == "drain_rate") {
			drain_rate_ = value.as_decimal().as_float();
			ASSERT_GE(drain_rate_, 0.0);
		} else if(key == "drained") {
			int drain = value.as_int();
			if(drain == drained_segments_) {
				return;
			}
			int animation_start_position = segments_-drained_segments_;
			animation_current_position_ = 0;
			drained_segments_after_anim_ = drain;
			if(drained_segments_after_anim_ < 0) {
				drained_segments_after_anim_ = 0;
			}
			if(drained_segments_after_anim_ > segments_) {
				drained_segments_after_anim_ = segments_;
			}
			int animation_end_position = segments_-drained_segments_after_anim_;
			animation_end_point_unscaled_ = animation_end_position - animation_start_position;
			animating_ = true;
			init();
		} else if(key == "max_width") { 
			bar_max_width_ = value.as_int();
			init();
		} else if(key == "animation_position") {
			animation_current_position_ = value.as_decimal().as_float();
		}
		widget::set_value(key, value);
	}
开发者ID:emmasteimann,项目名称:frogatto,代码行数:47,代码来源:bar_widget.cpp


示例3: TEST_F

TEST_F(LayoutTextTest, WidthLengthBeyondLength) {
  setBasicBody("x");
  // Width may vary by platform and we just want to make sure it's something
  // roughly reasonable.
  float width = getBasicText()->width(0u, 2u, LayoutUnit(), LTR, false);
  ASSERT_GE(width, 4.f);
  ASSERT_LE(width, 20.f);
}
开发者ID:mirror,项目名称:chromium,代码行数:8,代码来源:LayoutTextTest.cpp


示例4: TEST_F

TEST_F(SemaphoreTest, timedwait) {
  semaphore->post();
  ASSERT_TRUE(semaphore->timedwait(0.1));
  Time start_time(Time::now());
  semaphore->timedwait(0.1);
  Time elapsed_time(Time::now() - start_time);
  ASSERT_GE(elapsed_time, Time(0.1));
}
开发者ID:respu,项目名称:yield,代码行数:8,代码来源:semaphore_test.cpp


示例5: TEST

TEST(BugKillingTests, RemoveLastBugIfDead) {
	bug_list.clear();
	bug_list.push_back(initBug(0, 0, EAST, 0));
	bug_list.push_back(initBug(0, 1, EAST, MOVE_HEALTH * 3));
	bug_list.push_back(initBug(0, 2, EAST, MOVE_HEALTH * 3));
	bug_list.push_back(initBug(0, 3, EAST, 0));
	initWorld();

	moveBugs();
	killDeadBugs();

	ASSERT_EQ(bug_list.size(), 2);
	ASSERT_EQ(world[0][1], EMPTY);
	ASSERT_GE(world[0][2], 0);
	ASSERT_GE(world[0][3], 0);
	ASSERT_EQ(world[0][4], EMPTY);
}
开发者ID:lemonade512,项目名称:EE312,代码行数:17,代码来源:main.cpp


示例6: TEST

/**
 * The only process we are really guaranteed to have is this test process itself.
 */
TEST( Process_List_Test, find_our_process )
{
  std::vector< PROCESSENTRY32W > v ;
  initialize_process_list( v, our_process_by_name(), copy_all() ) ;
  size_t size( v.size() );
  EXPECT_EQ( 1u, size );    // Please, don't run multiple test executables simultaneously
  ASSERT_GE( 1u, size );
}
开发者ID:suninf,项目名称:adblockplusie,代码行数:11,代码来源:process_test.cpp


示例7: TEST

/**
 * Locate the PID of our process using the
 */
TEST(Process_List_Test, find_our_process_in_set)
{
  std::vector<DWORD> v;
  initialize_process_list(v, find_in_set, CopyPID());
  size_t size(v.size());
  EXPECT_EQ(size, 1u);      // Please, don't run multiple test executables simultaneously
  ASSERT_GE(size, 1u);
}
开发者ID:erikvold,项目名称:new-adblockplusie,代码行数:11,代码来源:process_test.cpp


示例8: TEST

// Does the PRNG generate random integers with approximately even distribution?
TEST(UtilTest, CanGenerateRandomInts)
{
    const int num_tests = 100000;

    long long avg = 0;
    for(size_t i = 0; i < num_tests; i++) {
        int res = rend_rand();
        ASSERT_LE(REND_RAND_MIN, res);
        ASSERT_GE(REND_RAND_MAX, res);
        avg += res;
    }
    avg /= num_tests;
    long long mid = REND_RAND_MIN + (REND_RAND_MAX - REND_RAND_MIN) / 2;
    long long err = mid / 100; // Test for +/-1% accuracy
    ASSERT_LE(mid - err, avg);
    ASSERT_GE(mid + err, avg);
}
开发者ID:lmurray,项目名称:rendasaurus,代码行数:18,代码来源:util.cpp


示例9: TEST_F

TEST_F(Allocate, Zeroed)
{
    void *zeroes = calloc(4096, 1);

    for (unsigned int heapMask : m_allHeaps) {
        SCOPED_TRACE(::testing::Message() << "heap " << heapMask);
        int fds[16];
        for (unsigned int i = 0; i < 16; i++) {
            int map_fd = -1;

            ASSERT_EQ(0, ion_alloc_fd(m_ionFd, 4096, 0, heapMask, 0, &map_fd));
            ASSERT_GE(map_fd, 0);

            void *ptr = NULL;
            ptr = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED, map_fd, 0);
            ASSERT_TRUE(ptr != NULL);

            memset(ptr, 0xaa, 4096);

            ASSERT_EQ(0, munmap(ptr, 4096));
            fds[i] = map_fd;
        }

        for (unsigned int i = 0; i < 16; i++) {
            ASSERT_EQ(0, close(fds[i]));
        }

        int newIonFd = ion_open();
        int map_fd = -1;

        ASSERT_EQ(0, ion_alloc_fd(newIonFd, 4096, 0, heapMask, 0, &map_fd));
        ASSERT_GE(map_fd, 0);

        void *ptr = NULL;
        ptr = mmap(NULL, 4096, PROT_READ, MAP_SHARED, map_fd, 0);
        ASSERT_TRUE(ptr != NULL);

        ASSERT_EQ(0, memcmp(ptr, zeroes, 4096));

        ASSERT_EQ(0, munmap(ptr, 4096));
        ASSERT_EQ(0, close(map_fd));
    }

    free(zeroes);

}
开发者ID:00zhengfu00,项目名称:platform_system_core,代码行数:46,代码来源:allocate_test.cpp


示例10: TEST

TEST(MoneyTest, comparisons) {
  ASSERT_LT(change::Money(10, 99), change::Money(11, 10));
  ASSERT_LE(change::Money(10, 99), change::Money(11, 10));
  ASSERT_EQ(change::Money(10, 99), change::Money(10, 99));
  ASSERT_LE(change::Money(10, 99), change::Money(10, 99));
  ASSERT_GE(change::Money(10, 99), change::Money(10, 99));
  ASSERT_GT(change::Money(11, 00), change::Money(10, 99));
  ASSERT_GE(change::Money(11, 00), change::Money(10, 99));

  EXPECT_TRUE(change::Money(10, 99) < change::Money(11, 10));
  EXPECT_TRUE(change::Money(10, 99) <= change::Money(11, 10));
  EXPECT_TRUE(change::Money(10, 99) == change::Money(10, 99));
  EXPECT_TRUE(change::Money(10, 99) <= change::Money(10, 99));
  EXPECT_TRUE(change::Money(10, 99) >= change::Money(10, 99));
  EXPECT_TRUE(change::Money(11, 00) > change::Money(10, 99));
  EXPECT_TRUE(change::Money(11, 00) >= change::Money(10, 99)); 
}
开发者ID:mgalushka,项目名称:cpp-start,代码行数:17,代码来源:ChangeTest.cpp


示例11: TEST_F

TEST_F( JihankiTest, GetJuiceList ) {
  auto list = jihanki.insert(1000).second;
  ASSERT_GE(list.size(), 1);

  Juice tmp = list[0];
  ASSERT_EQ("cola", tmp.name);
  ASSERT_EQ(120,    tmp.price);
}
开发者ID:datsuns,项目名称:jihanki,代码行数:8,代码来源:TestJihanki.cpp


示例12: TEST_F

TEST_F(StateMachineTests, AdvancedConnection) {
    ASSERT_EQ(BST_MODE_CONNECTING_TO_BOOTSTRAP, bst_get_state());
    bst_periodic();
    ASSERT_EQ(BST_MODE_WAITING_FOR_DATA, bst_get_state());

    prv_instance.options.retry_connecting_to_destination_network = 2;
    prv_instance.options.need_advanced_connection = true;

    { // Send hello packet now
        bst_udp_hello_receive_pkt_t pkt;
        prv_generate_test_hello(&pkt);
        bst_network_input((char*)&pkt,sizeof(bst_udp_hello_receive_pkt_t));
    }

    bst_periodic();

    { // Send bootstrap packet
        bst_udp_bootstrap_receive_pkt_t pkt;
        prv_generate_test_data(&pkt, true);
        bst_network_input((char*)&pkt,sizeof(bst_udp_bootstrap_receive_pkt_t));
    }

    ASSERT_EQ(BST_MODE_WAITING_FOR_DATA, prv_instance.state.state);
    bst_periodic();
    ASSERT_EQ(BST_STATE_CONNECTED, bst_get_connection_state());
    ASSERT_EQ(BST_MODE_CONNECTING_TO_DEST, prv_instance.state.state);
    ASSERT_EQ(0, retry_advanced_connection);

    // Expect no further connect to advanced until timeout_connecting_state_ms is over
    for(unsigned i=0;i<5;++i) {
        bst_periodic();
    }

    ASSERT_EQ(BST_STATE_CONNECTED, bst_get_connection_state());
    ASSERT_GE(1, retry_advanced_connection);

    // Expect second try to connect to advanced
    addTimeMsOverwrite(prv_instance.options.timeout_connecting_state_ms+10);

    ASSERT_GE(2, retry_advanced_connection);
    next_connect_state = BST_STATE_CONNECTED_ADVANCED;

    bst_periodic();

    ASSERT_EQ(BST_STATE_CONNECTED_ADVANCED, bst_get_connection_state());
}
开发者ID:Openhab-Nodes,项目名称:libNodesBootstrap,代码行数:46,代码来源:statemachine_tests.cpp


示例13: TEST_F

TEST_F(ConstexprMathTest, constexpr_add_overflow_clamped) {
  for (int a = kInt8Min; a <= kInt8Max; a++) {
    for (int b = kInt8Min; b <= kInt8Max; b++) {
      int c = folly::constexpr_clamp(a + b, int(kInt8Min), int(kInt8Max));
      int8_t a1 = a;
      int8_t b1 = b;
      int8_t c1 = folly::constexpr_add_overflow_clamped(a1, b1);
      ASSERT_LE(c1, kInt8Max);
      ASSERT_GE(c1, kInt8Min);
      ASSERT_EQ(c1, c);
    }
  }

  for (int a = 0; a <= kUInt8Max; a++) {
    for (int b = 0; b <= kUInt8Max; b++) {
      int c = folly::constexpr_clamp(a + b, 0, int(kUInt8Max));
      uint8_t a1 = a;
      uint8_t b1 = b;
      uint8_t c1 = folly::constexpr_add_overflow_clamped(a1, b1);
      ASSERT_LE(c1, kUInt8Max);
      ASSERT_GE(c1, 0);
      ASSERT_EQ(c1, c);
    }
  }

  constexpr auto v1 =
      folly::constexpr_add_overflow_clamped(int64_t(23), kInt64Max - 12);
  EXPECT_EQ(kInt64Max, v1);

  constexpr auto v2 =
      folly::constexpr_add_overflow_clamped(int64_t(23), int64_t(12));
  EXPECT_EQ(int64_t(35), v2);

  constexpr auto v3 =
      folly::constexpr_add_overflow_clamped(int64_t(-23), int64_t(12));
  EXPECT_EQ(int64_t(-11), v3);

  constexpr auto v4 =
      folly::constexpr_add_overflow_clamped(int64_t(-23), int64_t(-12));
  EXPECT_EQ(int64_t(-35), v4);

  constexpr auto v5 =
      folly::constexpr_add_overflow_clamped(uint64_t(23), kUInt64Max - 12);
  EXPECT_EQ(kUInt64Max, v5);
}
开发者ID:JacobMao,项目名称:folly,代码行数:45,代码来源:ConstexprMathTest.cpp


示例14: advance_head

 void safe_circular_char_buffer::
 advance_head(const std::streamsize advance_len) {
   ASSERT_GE(advance_len, 0);
   ASSERT_LE(advance_len, size());
   // advance the head forward as far as possible
   head += advance_len;
   // If head wraps around move head to begginning and then offset
   if (head >= bufsize) head -= bufsize;    
 } // end of advance head
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:9,代码来源:safe_circular_char_buffer.cpp


示例15: TEST

TEST(scheduledreporter, test) {
	StubScheduledReporter scheduled_reporter(MetricRegistry::DEFAULT_REGISTRY(),
			boost::chrono::milliseconds(1));
	scheduled_reporter.start(boost::chrono::milliseconds(100));
	boost::this_thread::sleep(boost::posix_time::seconds(1));
	scheduled_reporter.stop();
	ASSERT_LE((size_t)9, scheduled_reporter.invocation_count());
	ASSERT_GE((size_t)11, scheduled_reporter.invocation_count());
}
开发者ID:QuantScientist3,项目名称:cppmetrics,代码行数:9,代码来源:test_scheduled_reporter.cpp


示例16: TEST

TEST ( Heap, make_heap )
{
    std::vector<int> numbers { 4, 3, 2, 5, 1 };
    AP::algorithms::make_heap(begin(numbers), end(numbers));
    for ( size_t i=0; i < numbers.size(); i++ )
    {
        ASSERT_GE( numbers[i], numbers[std::floor( (i-1)/2 )]);
    }
}
开发者ID:uahic,项目名称:AlgorithmPractice,代码行数:9,代码来源:tests.cpp


示例17: TEST

TEST(getcwd, manual_path_max) {
  char* buf = new char[PATH_MAX];
  errno = 0;
  char* cwd = getcwd(buf, PATH_MAX);
  ASSERT_TRUE(cwd == buf);
  ASSERT_EQ(0, errno);
  ASSERT_GE(strlen(cwd), 1U);
  delete[] cwd;
}
开发者ID:0xDEC0DE8,项目名称:platform_bionic,代码行数:9,代码来源:getcwd_test.cpp


示例18: TEST

TEST(adf, devices) {
    adf_id_t *devs;
    ssize_t n_devs = adf_devices(&devs);
    free(devs);

    ASSERT_GE(n_devs, 0) << "enumerating ADF devices failed: " <<
            strerror(-n_devs);
    ASSERT_TRUE(devs != NULL);
}
开发者ID:2Habibie,项目名称:platform_system_core,代码行数:9,代码来源:adf_test.cpp


示例19: lock

void ReqRepHelloWorldRequester::waitDiscovery()
{
    std::unique_lock<std::mutex> lock(mutexDiscovery_);

    if(matched_ < 2)
        cvDiscovery_.wait_for(lock, std::chrono::seconds(10));

    ASSERT_GE(matched_, 2u);
}
开发者ID:dhood,项目名称:Fast-RTPS,代码行数:9,代码来源:ReqRepHelloWorldRequester.cpp


示例20: TEST_F

TEST_F(MongoDriverTest, FindOneProject)
{
  bson::Document d = c.findOne(FINDCOLL, {{"a", 5}}, {{"a", 1}});
  ASSERT_GE(2, d.field_names().size()); //can still have the _id apparently... ugh
  ASSERT_EQ(5, d["a"].data<int>());
  ASSERT_EQ(1, d.field_names().count("a"));
  ASSERT_EQ(1, d.field_names().count("_id"));
  ASSERT_EQ(0, d.field_names().count("b"));
}
开发者ID:Lumate,项目名称:MongoDB-Cpp,代码行数:9,代码来源:find.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ASSERT_HOST函数代码示例发布时间:2022-05-30
下一篇:
C++ ASSERT_GC_OBJECT_INHERITS函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap