コード例 #1
0
ファイル: mini-test.c プロジェクト: dov/gemtcl
int main()
{
    int count_ok = 0, count_failed;
    XnmValue *val = NULL;
    int ret;
    int val_int, len;
    gboolean val_bool = FALSE;
    const gchar *val_const_gchar;
    GError *error = NULL;
    GString *gs;

    ret = xnm_parse_string(test_string,
                           // output
                           &val,
                           &error);

    count_ok += test_ok(error == NULL && val != NULL,                       1);
    count_ok += test_ok(val->ref_count == 1,                                2);
    count_ok += test_ok(val->type == XNM_TABLE,                             3);
    ret = xnm_value_get_int(val, "junk/tires", &val_int);
    count_ok += test_ok(ret == 0,                                           4);
    count_ok += test_ok(val_int == 42,                                      5);

    xnm_value_table_set_key_value_string(val, "foo", "bar");
    ret = xnm_value_get_const_string(val, "foo", &val_const_gchar);
    count_ok += test_ok(strcmp(val_const_gchar, "bar")==0,                  6);

    ret = xnm_value_get_values(val,
                               "junk/tires", XNM_GET_INT, &val_int,
                               "pineapple", XNM_GET_STRING, &val_const_gchar,
                               "reflection", XNM_GET_BOOL, &val_bool,
                               NULL);
    count_ok += test_ok(ret== 0,                                            7);
    count_ok += test_ok(val_int == 42,                                      8);
    //    count_ok += test_ok(strcmp(val_const_gchar, "ananas")==0,               9);
    count_ok += test_ok(val_bool == TRUE,                                  10);

    xnm_value_table_set_key_value_string(val, "junk", "43");
    ret = xnm_value_get_const_string(val, "junk", &val_const_gchar);
    count_ok += test_ok(strcmp(val_const_gchar, "43")==0,                  11);

    xnm_value_unref(val);

    /*======================================================================
    //  End of tests. Create summary.
    //----------------------------------------------------------------------*/
    count_failed = num_tests-count_ok;

    if (count_failed == 0)
        printf("All tests passed. :-)\n");
    else
        printf("%d out of %d tests failed.\n", num_tests-count_ok, num_tests);

    if (count_failed == 0)
        exit(0);
    else
        exit(-1);
}
コード例 #2
0
static void test_SecDbExecWithSql(SecDbConnectionRef dbconn, CFStringRef sql CF_CONSUMED, const char *directive,
                                        const char *reason, const char *file, unsigned line) {
    CFErrorRef execError = NULL;
    bool is_ok = !!(SecDbExec(dbconn, sql, &execError));
    dispatch_sync(count_queue, ^{
        test_ok(is_ok, test_create_description("exec %@: %@", sql, execError), directive, reason, file, line, NULL);
    });
コード例 #3
0
ファイル: tsock.c プロジェクト: cdaffara/symbiandump-os2
/**
@SYMTestCaseID          SYSLIB-STDLIB-CT-1119
@SYMTestCaseDesc	    Tests for the unsupported option values in setsockopt
@SYMTestPriority 	    High
@SYMTestActions  	    Tests for creation of a socket and setting unsupported options on a socket
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/					
void testSimple()
	{
	int fd1;
	int err;
	int optionbuf[20];
	size_t optionsize;

	//Creating stream sockets to be used in the test
	test_Next("Create stream sockets");
	fd1=socket(AF_INET, SOCK_STREAM, 0);
	test_ok(fd1>=0);

	optionbuf[0]=7*1024;
	optionsize=sizeof(optionbuf[0]);
	
	//valid option e.g SO_SNDBUF(positive value 3)
	err=setsockopt(fd1,SOL_SOCKET,SO_SNDBUF,optionbuf,optionsize);
	p=_REENT;
	//No error in setsockopt with returned value in p->_errno=0
	test(err==0);
	test(p->_errno==0);


	//invalid(not supported) option e.g IP_ADD_MEMBERSHIP(negative value -8)
	err=setsockopt(fd1,SOL_SOCKET,IP_ADD_MEMBERSHIP,optionbuf,optionsize);
	p=_REENT;
	//Error in setsockopt with returned value in p->_errno=ENOSYS(88)
	test(err==-1);
	test(p->_errno==ENOSYS);
	
	}
コード例 #4
0
ファイル: main.c プロジェクト: txdv/cmark
int main() {
	int retval;
	test_batch_runner *runner = test_batch_runner_new();

	version(runner);
	constructor(runner);
	accessors(runner);
	node_check(runner);
	iterator(runner);
	iterator_delete(runner);
	create_tree(runner);
	hierarchy(runner);
	parser(runner);
	render_html(runner);
	utf8(runner);
	line_endings(runner);
	numeric_entities(runner);
	test_cplusplus(runner);

	test_print_summary(runner);
	retval =  test_ok(runner) ? 0 : 1;
	free(runner);

	return retval;
}
コード例 #5
0
void test_skip(const char *reason, int how_many, int unless)
{
    if (unless)
        return;

    int done;
    for (done = 0; done < how_many; ++done)
        test_ok(1, NULL, "skip", reason, __FILE__, __LINE__, NULL);
}
コード例 #6
0
ファイル: harness.c プロジェクト: CODECOMMUNITY/swift-cmark
void
test_print_summary(test_batch_runner *runner)
{
	int num_passed  = runner->num_passed;
	int num_skipped = runner->num_skipped;
	int num_failed  = runner->num_failed;

	fprintf(stderr, "%d tests passed, %d failed, %d skipped\n",
		num_passed, num_failed, num_skipped);

	if (test_ok(runner)) {
		fprintf(stderr, "PASS\n");
	}
	else {
		fprintf(stderr, "FAIL\n");
	}
}
コード例 #7
0
ファイル: fp80_cvtf.c プロジェクト: AndrewScull/gem5
static void
test_cvtf(const char *name, double fin)
{
    fp80_t v80 = fp80_cvfd(fin);
    double v64 = fp80_cvtd(v80);

    test_diag("Conversion '%e' -> fp80 -> double: %e", fin, v64);

    printf("# ");
    fp80_debug_dump(stdout, v80);
    if (v64 == fin ||
        (isnan(fin) && isnan(v64) && signbit(fin) == signbit(v64))) {
        test_ok(name);
    } else {
        test_diag("MISMATCH: %e != %e", fin, v64);
        test_fail(name);
    }
}
コード例 #8
0
ファイル: TNETDB.C プロジェクト: cdaffara/symbiandump-os2
/**
@SYMTestCaseID          SYSLIB-STDLIB-CT-1073
@SYMTestCaseDesc	    Tests for ARPA net functions
@SYMTestPriority 	    High
@SYMTestActions  	    Tests for get host by name and host by address functions
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
void testNetDB()
	{
	char hostname[128];
	struct in_addr addr, *addrp;
	int err, i;
	struct hostent *hp;

	test_Next("Get Host Name");

	err=gethostname(hostname,sizeof(hostname));
	test(err==0);
	printf("  hostname = >%s<\n", hostname);

	test_Next("Get Host By Name");

	for (i=0; i<N_NAMES; i++)
		{
		hp=gethostbyname(names[i][0]);
		test_ok(hp!=0);
		addrp=(struct in_addr*)(hp->h_addr_list[0]);
		printf("  %-30s => address %-15s\n", hp->h_name, inet_ntoa(*addrp));
		test(strcasecmp(hp->h_name,names[i][0])==0);
		test(addrp->s_addr==inet_addr(names[i][1]));
		}

	hp=gethostbyname("nosuchname.symbian.com");
	test_errno(hp==0,ENOENT);
	test(errno==HOST_NOT_FOUND);

	test_Next("Get Address of \"\"");
	hp=gethostbyname("");
	test_ok(hp!=0);
	addrp=(struct in_addr*)(hp->h_addr_list[0]);
	printf("  %-30s => address %-15s\n", hp->h_name, inet_ntoa(*addrp));

	test_Next("Get Host By Addr");

	for (i=0; i<N_NAMES; i++)
		{
		addr.s_addr=inet_addr(names[i][1]);
		hp=gethostbyaddr((const char *)&addr,sizeof(addr),AF_INET);
		test_ok(hp!=0);
		addrp=(struct in_addr*)(hp->h_addr_list[0]);
		printf("  address %-15s => %s\n", inet_ntoa(*addrp), hp->h_name);
		test(addrp->s_addr==addr.s_addr);
		test(strcasecmp(hp->h_name,names[i][2])==0);
		}

	addr.s_addr=inet_addr("10.11.199.255");
	hp=gethostbyaddr((const char *)&addr,sizeof(addr),AF_INET);
	test_errno(hp==0,ENOENT);
	test(errno==HOST_NOT_FOUND);
	
/*
	struct sockaddr_in testaddr;
	int fd;
	test_Next("Connect to the Imperial College Echo server");

	fd=socket(AF_INET, SOCK_STREAM, 0);
	test_ok(fd>=0);
	testaddr.sin_family=AF_INET;
	testaddr.sin_addr.s_addr=inet_addr("193.63.255.1");
	testaddr.sin_port=htons(7);	// echo
	err=connect(fd,(struct sockaddr*)&testaddr, sizeof(testaddr));
	test(err==0);
	close(fd);
*/

	test_Next("Get Address of roundrobin.test.intra which has multiple address");
	hp=gethostbyname("roundrobin.test.intra");	
	test_ok(hp!=0);

	if (hp)
		{
		if (hp->h_addr_list)
			{
			int Index = 0;
			while (hp->h_addr_list[Index])
				{
				addrp = (struct in_addr*)(hp->h_addr_list[Index]);
				printf("  %-30s => address %-15s\n", hp->h_name, inet_ntoa(*addrp));
				Index++;
				}
			}
		}

	test_Next("Get Host name of 192.168.255.4 which has multiple host name");
	addr.s_addr=inet_addr("192.168.255.4");
	hp=gethostbyaddr((const char *)&addr,sizeof(addr),AF_INET);
	test_ok(hp!=0);

	if (hp)
		{
		addrp=(struct in_addr*)(hp->h_addr_list[0]);
		printf("  address %-15s => %s\n", inet_ntoa(*addrp), hp->h_name);

		if (hp->h_aliases)
			{
			int Index = 0;
			while (hp->h_aliases[Index])
				{
				printf("  address %-15s => %s\n", inet_ntoa(*addrp), hp->h_aliases[Index]);
				Index++;
				}
			}
		}

	if (close_console)
		{
		test_Close();
		close(0);
		close(1);
		close(2);
		}
	}