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

C++ ATF_REQUIRE_STREQ函数代码示例

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

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



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

示例1: ATF_TC_BODY

ATF_TC_BODY(fork, tc)
{
    fprintf(stdout, "Should not get into child\n");
    fprintf(stderr, "Should not get into child\n");
    pid_t pid = atf_utils_fork();
    if (pid == 0) {
        fprintf(stdout, "Child stdout\n");
        fprintf(stderr, "Child stderr\n");
        exit(EXIT_SUCCESS);
    }

    int status;
    ATF_REQUIRE(waitpid(pid, &status, 0) != -1);
    ATF_REQUIRE(WIFEXITED(status));
    ATF_REQUIRE_EQ(EXIT_SUCCESS, WEXITSTATUS(status));

    atf_dynstr_t out_name;
    RE(atf_dynstr_init_fmt(&out_name, "atf_utils_fork_%d_out.txt", (int)pid));
    atf_dynstr_t err_name;
    RE(atf_dynstr_init_fmt(&err_name, "atf_utils_fork_%d_err.txt", (int)pid));

    char buffer[1024];
    read_file(atf_dynstr_cstring(&out_name), buffer, sizeof(buffer));
    ATF_REQUIRE_STREQ("Child stdout\n", buffer);
    read_file(atf_dynstr_cstring(&err_name), buffer, sizeof(buffer));
    ATF_REQUIRE_STREQ("Child stderr\n", buffer);

    atf_dynstr_fini(&err_name);
    atf_dynstr_fini(&out_name);
}
开发者ID:jaredmcneill,项目名称:netbsd-src,代码行数:30,代码来源:utils_test.c


示例2: ATF_TC_BODY

ATF_TC_BODY(pkgdb_get_virtualpkg_test, tc)
{
	xbps_dictionary_t pkgd;
	struct xbps_handle xh;
	const char *tcsdir, *pkgver;

	/* get test source dir */
	tcsdir = atf_tc_get_config_var(tc, "srcdir");

	memset(&xh, 0, sizeof(xh));
	strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
	strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
	xh.flags = XBPS_FLAG_DEBUG;
	ATF_REQUIRE_EQ(xbps_init(&xh), 0);

	pkgd = xbps_pkgdb_get_virtualpkg(&xh, "mixed");
	ATF_REQUIRE_EQ(xbps_object_type(pkgd), XBPS_TYPE_DICTIONARY);
	xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
	ATF_REQUIRE_STREQ(pkgver, "virtual-mixed-0.1_1");

	pkgd = xbps_pkgdb_get_virtualpkg(&xh, "mixed>0");
	ATF_REQUIRE_EQ(xbps_object_type(pkgd), XBPS_TYPE_DICTIONARY);
	xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
	ATF_REQUIRE_STREQ(pkgver, "virtual-mixed-0.1_1");

	pkgd = xbps_pkgdb_get_virtualpkg(&xh, "mixed<2");
	ATF_REQUIRE_EQ(xbps_object_type(pkgd), XBPS_TYPE_DICTIONARY);
	xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
	ATF_REQUIRE_STREQ(pkgver, "virtual-mixed-0.1_1");

	pkgd = xbps_pkgdb_get_virtualpkg(&xh, "mixed-0.1_1");
	ATF_REQUIRE_EQ(xbps_object_type(pkgd), XBPS_TYPE_DICTIONARY);
	xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
	ATF_REQUIRE_STREQ(pkgver, "virtual-mixed-0.1_1");
}
开发者ID:indianpoptart,项目名称:xbps,代码行数:35,代码来源:main.c


示例3: ATF_TC_BODY

ATF_TC_BODY(sdl_print, tc)
{
	char buf[1024];
	char res[1024];
	int r, e;
	size_t l = sizeof(buf);
	struct sockaddr_dl sdl;

	memset(&sdl, 0, sizeof(sdl));
	for (size_t i = 0; i < __arraycount(tst); i++) {
		memcpy(&sdl.sdl_addr, &tst[i].ia, sizeof(sdl.sdl_addr));
		sdl.sdl_index = (uint16_t)i;
		r = sdl_print(buf, l, &sdl);
		e = snprintf(res, l, "[%s]:%zu", tst[i].str, i);
		ATF_REQUIRE_STREQ(buf, res);
		ATF_REQUIRE_EQ(r, e);
	}

	l = 8;
	for (size_t i = 0; i < __arraycount(tst); i++) {
		memcpy(&sdl.sdl_addr, &tst[i].ia, sizeof(sdl.sdl_addr));
		sdl.sdl_index = (uint16_t)i;
		r = sdl_print(buf, l, &sdl);
		e = snprintf(res, l, "[%s]:%zu", tst[i].str, i);
		ATF_REQUIRE_STREQ(buf, res);
		ATF_REQUIRE_EQ(r, e);
	}
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:28,代码来源:t_print.c


示例4: ATF_TC_BODY

ATF_TC_BODY(reregister_reg, tc)
{
	char buf[1024];
	int localfd, etcfd;
	ssize_t n;
	int tfd;

	etcfd = open("/etc/passwd", O_RDONLY);
	ATF_REQUIRE(etcfd != -1);

	localfd = open("./testfile", O_RDWR | O_CREAT, 0666);
	ATF_REQUIRE(localfd != -1);

	ATF_REQUIRE_EQ(write(localfd, TESTSTR1, TESTSTR1SZ), TESTSTR1SZ);
	/* testfile now contains test string */

	rump_init();

	ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH1, "/etc/passwd",
	    RUMP_ETFS_REG), 0);
	tfd = rump_sys_open(TESTPATH1, O_RDONLY);
	ATF_REQUIRE(tfd != -1);
	ATF_REQUIRE(rump_sys_read(tfd, buf, sizeof(buf)) > 0);
	rump_sys_close(tfd);
	rump_pub_etfs_remove(TESTPATH1);

	ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH2, "./testfile",
	    RUMP_ETFS_REG), 0);
	tfd = rump_sys_open(TESTPATH2, O_RDWR);
	ATF_REQUIRE(tfd != -1);
	memset(buf, 0, sizeof(buf));
	ATF_REQUIRE((n = rump_sys_read(tfd, buf, sizeof(buf))) > 0);

	/* check that we have what we expected */
	ATF_REQUIRE_STREQ(buf, TESTSTR1);

	/* ... while here, check that writing works too */
	ATF_REQUIRE_EQ(rump_sys_lseek(tfd, 0, SEEK_SET), 0);
	ATF_REQUIRE(TESTSTR1SZ <= TESTSTR2SZ);
	ATF_REQUIRE_EQ(rump_sys_write(tfd, TESTSTR2, TESTSTR2SZ), TESTSTR2SZ);

	memset(buf, 0, sizeof(buf));
	ATF_REQUIRE_EQ(lseek(localfd, 0, SEEK_SET), 0);
	ATF_REQUIRE(read(localfd, buf, sizeof(buf)) > 0);
	ATF_REQUIRE_STREQ(buf, TESTSTR2);
	close(etcfd);
	close(localfd);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:48,代码来源:t_etfs.c


示例5: ATF_TC_BODY

ATF_TC_BODY(find_all_orphans_test, tc)
{
	struct xbps_handle xh;
	xbps_array_t res;
	xbps_dictionary_t pkgd;
	xbps_string_t pstr;
	const char *pkgver, *tcsdir;
	unsigned int i;

	/* get test source dir */
	tcsdir = atf_tc_get_config_var(tc, "srcdir");

	memset(&xh, 0, sizeof(xh));
	xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
	xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
	ATF_REQUIRE_EQ(xbps_init(&xh), 0);

	pstr = xbps_string_create();
	res = xbps_find_pkg_orphans(&xh, NULL);
	for (i = 0; i < xbps_array_count(res); i++) {
		pkgd = xbps_array_get(res, i);
		xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
		xbps_string_append_cstring(pstr, pkgver);
		xbps_string_append_cstring(pstr, "\n");
	}
	printf("%s", xbps_string_cstring_nocopy(pstr));

	ATF_REQUIRE_STREQ(xbps_string_cstring_nocopy(pstr), expected_output_all);
}
开发者ID:DirectorX,项目名称:xbps,代码行数:29,代码来源:main.c


示例6: ATF_TC_BODY

ATF_TC_BODY(vprintf__empty, tc)
{
    char* buffer;
    kyua_error_t error = call_vprintf(&buffer, "%s", "");
    ATF_REQUIRE(!kyua_error_is_set(error));
    ATF_REQUIRE_STREQ("", buffer);
}
开发者ID:namore,项目名称:kyua,代码行数:7,代码来源:text_test.c


示例7: ATF_TC_BODY

ATF_TC_BODY(mbsnrtowcs, tc)
{
	size_t i;
	const struct test *t;
	mbstate_t state;
	wchar_t buf[64];
	const char *src;
	size_t len;

	for (i = 0; i < __arraycount(tests); ++i) {
		t = &tests[i];
		ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
		ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
		memset(&state, 0, sizeof(state));
		src = t->data;
		len = mbsnrtowcs(buf, &src, t->limit,
		    __arraycount(buf), &state);
		ATF_REQUIRE_EQ(src, t->data + t->limit);
		ATF_REQUIRE_EQ(len, t->output1_len);
		ATF_REQUIRE(wmemcmp(t->output1, buf, len) == 0);
		len = mbsnrtowcs(buf, &src, strlen(src) + 1,
		    __arraycount(buf), &state);
		ATF_REQUIRE_EQ(len, strlen(t->data) - t->limit);
		ATF_REQUIRE(wmemcmp(t->output2, buf, len + 1) == 0);
		ATF_REQUIRE_EQ(src, NULL);
	}
}
开发者ID:2asoft,项目名称:freebsd,代码行数:27,代码来源:t_mbsnrtowcs.c


示例8: ATF_TC_BODY

ATF_TC_BODY(concat__two, tc)
{
    char* path;
    ATF_REQUIRE(!kyua_error_is_set(kyua_fs_concat(&path, "foo", "bar", NULL)));
    ATF_REQUIRE_STREQ("foo/bar", path);
    free(path);
}
开发者ID:phoatfreebsd,项目名称:kyua,代码行数:7,代码来源:fs_test.c


示例9: ATF_TC_BODY

ATF_TC_BODY(usage_error_format__args, tc)
{
    kyua_error_t error = kyua_usage_error_new("%s message %d", "A", 123);
    char buffer[1024];
    kyua_error_format(error, buffer, sizeof(buffer));
    ATF_REQUIRE_STREQ("A message 123", buffer);
    kyua_error_free(error);
}
开发者ID:Bhudipta,项目名称:minix,代码行数:8,代码来源:error_test.c


示例10: h_mbtowc

static void
h_mbtowc(const char *locale, const char *illegal, const char *legal)
{
	char buf[64];
	size_t stateful, ret;
	char *str;

	ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
#ifdef __NetBSD__
	ATF_REQUIRE(setlocale(LC_CTYPE, locale) != NULL);
#else
	if (setlocale(LC_CTYPE, locale) == NULL) {
		fprintf(stderr, "Locale %s not found.\n", locale);
		return;
	}
#endif

	ATF_REQUIRE((str = setlocale(LC_ALL, NULL)) != NULL);
	(void)printf("Using locale: %s\n", str);

	stateful = wctomb(NULL, L'\0');
	(void)printf("Locale is state-%sdependent\n",
		stateful ? "in" : "");

	/* initialize internal state */
	ret = mbtowc(NULL, NULL, 0);
	ATF_REQUIRE(stateful ? ret : !ret);

	(void)strvis(buf, illegal, VIS_WHITE | VIS_OCTAL);
	(void)printf("Checking illegal sequence: \"%s\"\n", buf);

	ret = mbtowc(NULL, illegal, strlen(illegal));
	(void)printf("mbtowc() returned: %zd\n", ret);
	ATF_REQUIRE_EQ(ret, (size_t)-1);
	(void)printf("errno: %s\n", strerror(errno));
	ATF_REQUIRE_EQ(errno, EILSEQ);

	/* if this is stateless encoding, this re-initialization is not required. */
	if (stateful) {
		/* re-initialize internal state */
		ret = mbtowc(NULL, NULL, 0);
		ATF_REQUIRE(stateful ? ret : !ret);
	}

	/* valid multibyte sequence case */
	(void)strvis(buf, legal, VIS_WHITE | VIS_OCTAL);
	(void)printf("Checking legal sequence: \"%s\"\n", buf);

	errno = 0;
	ret = mbtowc(NULL, legal, strlen(legal));
	(void)printf("mbtowc() returned: %zd\n", ret);
	ATF_REQUIRE(ret != (size_t)-1);
	(void)printf("errno: %s\n", strerror(errno));
	ATF_REQUIRE_EQ(errno, 0);

	(void)printf("Ok.\n");
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:57,代码来源:t_mbtowc.c


示例11: ATF_TC_BODY

ATF_TC_BODY(check_files, tc)
{
	FILE *f;
	unsigned char *sum;

	f = fopen("foo", "w");
	fprintf(f, "bar\n");
	fclose(f);

	sum = pkg_checksum_file("foo", PKG_HASH_TYPE_SHA256_HEX);
	ATF_REQUIRE_STREQ(sum, "7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730");

	ATF_CHECK(pkg_checksum_validate_file("foo", "7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730") == 0);
	free(sum);

	sum=pkg_checksum_generate_file("foo", PKG_HASH_TYPE_SHA256_HEX);
	ATF_REQUIRE_STREQ(sum, "1$7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730");
}
开发者ID:heliocentric,项目名称:pkg,代码行数:18,代码来源:checksum.c


示例12: ATF_TC_BODY

ATF_TC_BODY(run_params_init__defaults, tc)
{
    kyua_run_params_t run_params;
    kyua_run_params_init(&run_params);

    ATF_REQUIRE_EQ(60, run_params.timeout_seconds);
    ATF_REQUIRE_EQ(getuid(), run_params.unprivileged_user);
    ATF_REQUIRE_EQ(getgid(), run_params.unprivileged_group);
    ATF_REQUIRE_STREQ(".", run_params.work_directory);
}
开发者ID:s5unty,项目名称:kyua,代码行数:10,代码来源:run_test.c


示例13: ATF_TC_BODY

ATF_TC_BODY(fork, tc)
{
    fprintf(stdout, "Should not get into child\n");
    fprintf(stderr, "Should not get into child\n");
    pid_t pid = atf_utils_fork();
    if (pid == 0) {
        fprintf(stdout, "Child stdout\n");
        fprintf(stderr, "Child stderr\n");
        exit(EXIT_SUCCESS);
    }

    int status;
    ATF_REQUIRE(waitpid(pid, &status, 0) != -1);
    ATF_REQUIRE(WIFEXITED(status));
    ATF_REQUIRE_EQ(EXIT_SUCCESS, WEXITSTATUS(status));

    char buffer[1024];
    read_file("atf_utils_fork_out.txt", buffer, sizeof(buffer));
    ATF_REQUIRE_STREQ("Child stdout\n", buffer);
    read_file("atf_utils_fork_err.txt", buffer, sizeof(buffer));
    ATF_REQUIRE_STREQ("Child stderr\n", buffer);
}
开发者ID:0xbda2d2f8,项目名称:freebsd,代码行数:22,代码来源:utils_test.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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