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

C++ ASSERT_EXIT函数代码示例

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

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



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

示例1: TEST

TEST(DEATHTEST, snprintf_fortified2) {
  ::testing::FLAGS_gtest_death_test_style = "threadsafe";
  foo myfoo;
  strcpy(myfoo.a, "012345678");
  size_t n = strlen(myfoo.a) + 2;
  ASSERT_EXIT(snprintf(myfoo.b, n, "a%s", myfoo.a), testing::KilledBySignal(SIGABRT), "");
}
开发者ID:MazWoz,项目名称:platform_bionic,代码行数:7,代码来源:fortify_test.cpp


示例2: TEST

TEST(DEATHTEST, strncpy2_fortified) {
  ::testing::FLAGS_gtest_death_test_style = "threadsafe";
  char dest[11];
  char src[10];
  memcpy(src, "0123456789", sizeof(src)); // src is not null terminated
  ASSERT_EXIT(strncpy(dest, src, sizeof(dest)), testing::KilledBySignal(SIGABRT), "");
}
开发者ID:junzhe,项目名称:platform_bionic,代码行数:7,代码来源:fortify_test.cpp


示例3: TEST

// one byte target with longer source (should fail)
TEST(Fortify1_DeathTest, strcpy4_fortified) {
  ::testing::FLAGS_gtest_death_test_style = "threadsafe";
  char buf[1];
  char *orig = strdup("12");
  ASSERT_EXIT(strcpy(buf, orig), testing::KilledBySignal(SIGABRT), "");
  free(orig);
}
开发者ID:AdrianoMartins,项目名称:bionic,代码行数:8,代码来源:fortify1_test.cpp


示例4: TEST

TEST(DEATHTEST, read_fortified) {
  ::testing::FLAGS_gtest_death_test_style = "threadsafe";
  char buf[1];
  size_t ct = atoi("2"); // prevent optimizations
  int fd = open("/dev/null", O_RDONLY);
  ASSERT_EXIT(read(fd, buf, ct), testing::KilledBySignal(SIGABRT), "");
  close(fd);
}
开发者ID:AOSP-S4,项目名称:platform_bionic,代码行数:8,代码来源:fortify_test.cpp


示例5: GetExecutablePathQuoted

void GetExecutablePathQuoted(wchar_t* outpath, int outpath_length)
{
    wchar_t* temppath = new wchar_t[outpath_length];
    GetExecutablePath(temppath, outpath_length);
    int result = swprintf_s(outpath, outpath_length, L"\"%s\"", temppath);
    ASSERT_EXIT((-1 != result), "swprintf_s(outpath)");
    delete[] temppath;
    temppath = 0;
}
开发者ID:KMayne,项目名称:5minutebreak,代码行数:9,代码来源:ExecutablePath.cpp


示例6: GetExecutablePath

void GetExecutablePath(wchar_t* outpath, int outpath_length)
{
    // This path is longer than MAX_PATH, do not use it with
    // windows api functions as you might get buffer overflows.

    wchar_t shortpath[1024];
    wchar_t longpath[1024];

    DWORD dw;

    dw = GetModuleFileName(NULL, shortpath, 1024);
    ASSERT_EXIT(dw, "GetModuleFileName()");

    dw = GetLongPathName(shortpath, longpath, 1024);
    ASSERT_EXIT(dw, "GetLongPathName()");

    swprintf_s(outpath, outpath_length, L"%s", longpath);
}
开发者ID:KMayne,项目名称:5minutebreak,代码行数:18,代码来源:ExecutablePath.cpp


示例7: TEST

TEST(ExampleTests, test_no_death){

    auto a = [] () {
        int a = 0;
        a = 7;
        int b = a;
        a = b;
        exit(0);
    };

    ASSERT_EXIT(a(), ::testing::ExitedWithCode(0), "");
}
开发者ID:Dexter245,项目名称:gauss_cpp,代码行数:12,代码来源:test_examples.cpp


示例8: TEST_F

TEST_F(properties_DeathTest, read_only) {
#if defined(__BIONIC__)

  // This test only makes sense if we're talking to the real system property service.
  struct stat sb;
  if (stat(PROP_FILENAME, &sb) == -1 && errno == ENOENT) {
    return;
  }

  ASSERT_EXIT(__system_property_add("property", 8, "value", 5), KilledByFault(), "");
#else // __BIONIC__
  GTEST_LOG_(INFO) << "This test does nothing.\n";
#endif // __BIONIC__
}
开发者ID:Decatf,项目名称:platform_bionic,代码行数:14,代码来源:system_properties_test.cpp


示例9: GetExecutableName

void GetExecutableName(wchar_t* outdir, int outdir_length)
{
    // Filename without extension.

    wchar_t longpath[1024];
    GetExecutablePath(longpath, _countof(longpath));

    wchar_t drive[3];
    wchar_t dir[768];
    wchar_t fname[256];
    wchar_t ext[32];

    errno_t result = _wsplitpath_s(longpath, drive, _countof(drive), dir, _countof(dir), fname, _countof(fname), ext, _countof(ext));
    ASSERT_EXIT((result == 0), "_wsplitpath_s(longpath)");

    swprintf_s(outdir, outdir_length, L"%s", fname);
}
开发者ID:KMayne,项目名称:5minutebreak,代码行数:17,代码来源:ExecutablePath.cpp


示例10: test_policy_priv_by_id

static int test_policy_priv_by_id(const char *bus,
				  struct kdbus_conn *conn_dst,
				  bool drop_second_user,
				  int parent_status,
				  int child_status)
{
	int ret = 0;
	uint64_t expected_cookie = time(NULL) ^ 0xdeadbeef;

	ASSERT_RETURN(conn_dst);

	ret = RUN_UNPRIVILEGED_CONN(unpriv, bus, ({
		ret = kdbus_msg_send(unpriv, NULL,
				     expected_cookie, 0, 0, 0,
				     conn_dst->id);
		ASSERT_EXIT(ret == child_status);
	}));
开发者ID:D-os,项目名称:kdbus,代码行数:17,代码来源:test-policy-priv.c


示例11: no_cancel_sync

static int no_cancel_sync(struct kdbus_conn *conn_src,
			  struct kdbus_conn *conn_dst)
{
	pid_t pid;
	int cancel_fd;
	int ret, status;
	struct kdbus_msg *msg = NULL;

	/* pass eventfd, but never signal it so it shouldn't have any effect */

	cancel_fd = eventfd(0, 0);
	ASSERT_RETURN_VAL(cancel_fd >= 0, cancel_fd);

	cookie++;
	pid = fork();
	ASSERT_RETURN_VAL(pid >= 0, pid);

	if (pid == 0) {
		ret = kdbus_msg_send_sync(conn_dst, NULL, cookie,
					  KDBUS_MSG_EXPECT_REPLY,
					  100000000ULL, 0, conn_src->id,
					  cancel_fd);
		ASSERT_EXIT(ret == 0);

		_exit(EXIT_SUCCESS);
	}

	ret = kdbus_msg_recv_poll(conn_src, 100, &msg, NULL);
	ASSERT_RETURN_VAL(ret == 0 && msg->cookie == cookie, -1);

	kdbus_msg_free(msg);

	ret = kdbus_msg_send_reply(conn_src, cookie, conn_dst->id);
	ASSERT_RETURN_VAL(ret >= 0, ret);

	ret = waitpid(pid, &status, 0);
	ASSERT_RETURN_VAL(ret >= 0, ret);

	if (WIFSIGNALED(status))
		return -1;

	return (status == EXIT_SUCCESS) ? 0 : -1;
}
开发者ID:adhideguchi,项目名称:kdbus,代码行数:43,代码来源:test-sync.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ ASSERT_FAIL函数代码示例发布时间:2022-05-30
下一篇:
C++ ASSERT_ERRNO_AND_EXIT函数代码示例发布时间: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