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


C++ CATCH函数代码示例

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


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

示例1: test_app_arguments_validate_ordinal_required_discontinuity

bool test_app_arguments_validate_ordinal_required_discontinuity (Test *test)
{
        char *argv[] = { "./app", "--argument" };
        int value_1;
        int value_2;

        AppArgument arguments[] = {
                ARGUMENT_ORDINAL_INTEGER (1, false, &value_1, "test"),
                ARGUMENT_ORDINAL_INTEGER (1, true, &value_2, "test"),
                ARGUMENT_END
        };

        TITLE ();
        CATCH (app_arguments (2, argv, arguments))
        CATCH (error_count () < 2);
        CATCH (error_at (1).error != ErrorAppArgumentOrdinalRequiredDiscontinuity);
        PASS ();
}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:18,代码来源:test-arguments-validate.c

示例2: confuga_lookup

CONFUGA_API int confuga_lookup (confuga *C, const char *path, confuga_fid_t *fid, confuga_off_t *size)
{
	int rc;
	enum CONFUGA_FILE_TYPE type;
	RESOLVE(path)
	debug(D_CONFUGA, "lookup(`%s')", unresolved_path);
	CATCH(lookup(C, path, fid, size, &type));
	PROLOGUE
}
开发者ID:NeilB879,项目名称:cctools,代码行数:9,代码来源:confuga_namespace.c

示例3: MailboxState_getAcl

int MailboxState_getAcl(T M, uint64_t userid, struct ACLMap *map)
{
	int i;
	volatile int t = DM_SUCCESS;
	gboolean gotrow = FALSE;
	uint64_t anyone;
	Connection_T c; ResultSet_T r; PreparedStatement_T s;

	g_return_val_if_fail(MailboxState_getId(M),DM_EGENERAL); 

	if (! (auth_user_exists(DBMAIL_ACL_ANYONE_USER, &anyone)))
		return DM_EQUERY;

	c = db_con_get();
	TRY
		s = db_stmt_prepare(c, "SELECT lookup_flag,read_flag,seen_flag,"
			"write_flag,insert_flag,post_flag,"
			"create_flag,delete_flag,deleted_flag,expunge_flag,administer_flag "
			"FROM %sacl "
			"WHERE mailbox_id = ? AND user_id = ?",DBPFX);
		db_stmt_set_u64(s, 1, MailboxState_getId(M));
		db_stmt_set_u64(s, 2, userid);
		r = db_stmt_query(s);
		if (! db_result_next(r)) {
			/* else check the 'anyone' user */
			db_stmt_set_u64(s, 2, anyone);
			r = db_stmt_query(s);
			if (db_result_next(r))
				gotrow = TRUE;
		} else {
			gotrow = TRUE;
		}

		if (gotrow) {
			i = 0;
			map->lookup_flag	= db_result_get_bool(r,i++);
			map->read_flag		= db_result_get_bool(r,i++);
			map->seen_flag		= db_result_get_bool(r,i++);
			map->write_flag		= db_result_get_bool(r,i++);
			map->insert_flag	= db_result_get_bool(r,i++);
			map->post_flag		= db_result_get_bool(r,i++);
			map->create_flag	= db_result_get_bool(r,i++);
			map->delete_flag	= db_result_get_bool(r,i++);
			map->deleted_flag	= db_result_get_bool(r,i++);
			map->expunge_flag	= db_result_get_bool(r,i++);
			map->administer_flag	= db_result_get_bool(r,i++);
		}
	CATCH(SQLException)
		LOG_SQLERROR;
		t = DM_EQUERY;
	FINALLY
		db_con_close(c);
	END_TRY;

	return t;
}
开发者ID:Alexander-KI,项目名称:dbmail,代码行数:56,代码来源:dm_mailboxstate.c

示例4: test_file_path_size_1

bool test_file_path_size_1 (Test *test)
{
	char *path;

	TITLE ();
	file_path_size (0);
	CATCH (!(path = directory_current_path ()));
	memory_destroy (path);
	PASS ();
}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:10,代码来源:test-file.c

示例5: test_pattern_search_create

bool test_pattern_search_create (Test *test)
{
	PatternSearch *search;
	const char *memory = "a";

	TITLE ();
	CATCH (!(search = pattern_search_create ((const unsigned char *)memory, string_length (memory) + 1, "a", true)));
	pattern_search_destroy (search);
	PASS ();
}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:10,代码来源:test-pattern-search.c

示例6: test_ascii_is_white_space

bool test_ascii_is_white_space (Test *test)
{
	int i;

	TITLE ();
	for (i = SCHAR_MIN; i <= SCHAR_MAX; i++) {
		if ((char)i == ' ' ||
		    (char)i == '\f' ||
		    (char)i == '\n' ||
		    (char)i == '\r' ||
		    (char)i == '\t' ||
		    (char)i == '\v') {
			CATCH (!ascii_is_white_space ((char)i));
		}
		else {
			CATCH (ascii_is_white_space ((char)i));
		}
	}
	PASS ();
}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:20,代码来源:test-ascii.c

示例7: test_file_close

bool test_file_close (Test *test)
{
	Directory *directory;
	File *file;
	char *path;

	TITLE ();
	CATCH (!(path = directory_current_path ()));
	CATCH (!string_append (&path, "/stage/open"));
        /*
                d stage/open
                f f1
         */
	CATCH (!(directory = directory_open (path)));
	string_destroy (path);
	CATCH (!directory_read (directory));
	CATCH (!(file = directory_find_file (directory, "f1")));
	file_close (file);
	directory_close (directory);
	PASS ();
}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:21,代码来源:test-file.c

示例8: test_big_int_add_function_call_1

bool test_big_int_add_function_call_1 (Test *test)
{
        BigInt *a, *b, *to;
        int i;

        TITLE ();
        CATCH (!(a = big_int_create (0)));
        CATCH (!(b = big_int_create (0)));
        CATCH (!(to = big_int_create (0)));
        a->memory[0] = 5U;
        b->memory[0] = 5U;
        for (i = 1; i < 32; i++) {
                a->memory[i] = 0U;
                b->memory[i] = 0U;
        }
        a->digits = 32;
        b->digits = 32;
        memory_commit_limit (memory_commit_size ());
        CATCH (big_int_add (a, b, to));
        CATCH (error_at (0).error != ErrorFunctionCall);
        CATCH (error_at (0).code != 1);
        big_int_destroy (a);
        big_int_destroy (b);
        big_int_destroy (to);
        PASS ();
}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:26,代码来源:test-big-int.c

示例9: test_file_readline_f2

bool test_file_readline_f2 (Test *test)
{
	Directory *directory;
	File *file;
	char *path;
	char *line;
	size_t bytes_read;

	TITLE ();
	CATCH (!(path = directory_current_path ()));
	CATCH (!string_append (&path, "/stage/readline"));
        /*
                d stage/readline
                f f2
                f f3 \
                         \
                        0 \
                        AB \
                        012 \
                        ABCD \
                        01234 \
                        ABCD \
                        012 \
                        AB \
                        0
                f f1
         */
	CATCH (!(directory = directory_open (path)));
	string_destroy (path);
	CATCH (!directory_read (directory));
	CATCH (!(file = directory_find_file (directory, "f2")));
	CATCH (!file_open (file));
	CATCH (!(line = string_create_with_size (1)));
	CATCH (!file_readline (file, line, &bytes_read));
	CATCH (bytes_read != 0);
	CATCH (memory_size (line) != 1);
	directory_close (directory);
	string_destroy (line);
	PASS ();
}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:40,代码来源:test-file.c

示例10: test_unsigned_long_long_private_max

bool test_unsigned_long_long_private_max (Test *test)
{
	unsigned int a, b, max;
	unsigned long long computed;

	TITLE ();
	for (max = 1; max < 9; max++) {
		a = 0;
		b = 0;
		unsigned_long_long_private_max (max - 1);
		do {
			if (a > max - 1 ||
			    b > max - 1 ||
			    a + b > max - 1) {
				CATCH (unsigned_long_long_add (a, b, &computed));
			}
			else {
				CATCH (!unsigned_long_long_add (a, b, &computed));
				CATCH (computed != a + b);
			}
			if (a > max - 1 ||
			    b > max - 1 ||
			    a * b > max - 1) {
				CATCH (unsigned_long_long_mul (a, b, &computed));
			}
			else {
				CATCH (!unsigned_long_long_mul (a, b, &computed));
				CATCH (computed != a * b);
			}
		} while (combinations_a_b (&a, &b, max, max));
	}
	PASS ();
}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:33,代码来源:test-defines.c

示例11: ccnet_db_statement_set_int

int
ccnet_db_statement_set_int (CcnetDBStatement *p, int idx, int x)
{
    TRY
        PreparedStatement_setInt (p->p, idx, x);
        RETURN (0);
    CATCH (SQLException)
        g_warning ("Error set int in prep stmt: %s.\n", Exception_frame.message);
        return -1;
    END_TRY;

    return -1;
}
开发者ID:ezhangle,项目名称:ccnet,代码行数:13,代码来源:ccnet-db.c

示例12: test_ascii_is_digit_octal

bool test_ascii_is_digit_octal (Test *test)
{
	int i;

	TITLE ();
	for (i = SCHAR_MIN; i <= SCHAR_MAX; i++) {
		if ((char)i == '0' ||
		    (char)i == '1' ||
		    (char)i == '2' ||
		    (char)i == '3' ||
		    (char)i == '4' ||
		    (char)i == '5' ||
		    (char)i == '6' ||
		    (char)i == '7') {
			CATCH (!ascii_is_digit_octal ((char)i));
		}
		else {
			CATCH (ascii_is_digit_octal ((char)i));
		}
	}
	PASS ();
}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:22,代码来源:test-ascii.c

示例13: python_save_file

char*
python_save_file(char **dest, const char *filename)
{
    char *ret;
    PyObject *module, *mainthing, *pyret;
    printf("the module being used for file is %s\n", config_get("module_file"));
    module = PyDict_GetItemString(modulemap, config_get("module_file"));
    CATCH(module, bottom_save_file);
    mainthing = PyObject_CallMethod(module, "init", NULL);
    CATCH(mainthing, bottom_save_file);
    pyret = PyObject_CallMethod(mainthing, "save_file", "s", filename);
    CATCH(pyret, bottom_save_file);
    ret = PyUnicode_AsUTF8(pyret);
    CATCH(ret, bottom_save_file);
    bottom_save_file: // label
    if (PyErr_Occurred()) {
        PyErr_Print();
    }
    *dest = strdup(ret);
    Py_DecRef(mainthing); Py_DecRef(pyret);
    return *dest;
}
开发者ID:Riamse,项目名称:notpuush,代码行数:22,代码来源:pythonengine.c

示例14: confuga_opendir

CONFUGA_API int confuga_opendir(confuga *C, const char *path, confuga_dir **D)
{
	int rc;
	RESOLVE(path);
	debug(D_CONFUGA, "opendir(`%s')", unresolved_path);
	*D = malloc(sizeof(confuga_dir));
	if (*D == NULL) CATCH(ENOMEM);
	DIR *dir = opendir(path);
	if(dir) {
		(*D)->C = C;
		(*D)->dir = dir;
		strcpy((*D)->path, unresolved_path);
		return 0;
	} else {
		CATCH(errno);
	}
out:
	debug(D_CONFUGA, "= %d (%s)", rc, strerror(rc));
	if (rc)
		free(*D);
	return rc;
}
开发者ID:xavierdingdev,项目名称:cctools,代码行数:22,代码来源:confuga_namespace.c

示例15: dm_sievescript_rename

int dm_sievescript_rename(uint64_t user_idnr, char *scriptname, char *newname)
{
	int active = 0;
	Connection_T c; ResultSet_T r; PreparedStatement_T s; volatile int t = FALSE;
	assert(scriptname);

	/* 
	 * According to the draft RFC, a script with the same
	 * name as an existing script should *atomically* replace it.
	 */
	c = db_con_get();
	TRY
		db_begin_transaction(c);

		s = db_stmt_prepare(c,"SELECT active FROM %ssievescripts WHERE owner_idnr = ? AND name = ?", DBPFX);
		db_stmt_set_u64(s,1, user_idnr);
		db_stmt_set_str(s,2, newname);
		r = db_stmt_query(s);

		if (db_result_next(r)) {
			active = db_result_get_int(r,0);

			db_con_clear(c);

			s = db_stmt_prepare(c, "DELETE FROM %ssievescripts WHERE owner_idnr = ? AND name = ?", DBPFX);
			db_stmt_set_u64(s, 1, user_idnr);
			db_stmt_set_str(s, 2, newname);
			db_stmt_exec(s);
		}

		db_con_clear(c);

		s = db_stmt_prepare(c, "UPDATE %ssievescripts SET name = ?, active = ? WHERE owner_idnr = ? AND name = ?", DBPFX);
		db_stmt_set_str(s, 1, newname);
		db_stmt_set_int(s, 2, active);
		db_stmt_set_u64(s, 3, user_idnr);
		db_stmt_set_str(s, 4, scriptname);
		db_stmt_exec(s);

		t = db_commit_transaction(c);

	CATCH(SQLException)
		LOG_SQLERROR;
		t = DM_EQUERY;
		db_rollback_transaction(c);
	FINALLY
		db_con_close(c);
	END_TRY;

	return t;
}
开发者ID:alyarskiy,项目名称:dbmail,代码行数:51,代码来源:dm_sievescript.c


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