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


C++ ASSERT2函数代码示例

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


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

示例1: ASSERT2

bool interval::subset_of(const interval& x) const {

	ASSERT2(lb <= ub, *this);
	ASSERT2(x.lb <= x.ub, x);

	return lb >= x.lb && ub <= x.ub;
}
开发者ID:baharev,项目名称:old_sandbox,代码行数:7,代码来源:interval.cpp

示例2: log

const interval log(const interval& x) {

	ASSERT2(x.lb <= x.ub, "x: "<<x);
	ASSERT2(0<x.lb, "x.lb = "<<x.lb);

	return interval(std::log(x.lb), std::log(x.ub));
}
开发者ID:baharev,项目名称:old_sandbox,代码行数:7,代码来源:interval.cpp

示例3: test2

int test2(int seed) {
	struct gameState *G = newGame();
	//struct gameState *Gcpy = newGame();
	int i;
	int numPlayers;
	int ret;
	int *k = getUniqueCards();
	printf("TEST #2: Number of players random testing\n");
	printf("\t should return 0 if 2 - 4; -1 otherwise\n");
	//random testing for number of players
	for(i = 0; i < NUMTRIALS; i++) {
		numPlayers = rand();
		ret = initializeGame(numPlayers, k, seed, G);
		if((numPlayers == 1) || (numPlayers == 2) || (numPlayers == 3) || (numPlayers == 4))
		{
			ASSERT2(ret, 0, "FAIL");
		}
		else
		{
			ASSERT2(ret, -1, "FAIL");
		}
	}
	printf("PASS\n");
	printf("----------------------\n");
	free(G);
	free(k);
}
开发者ID:cr8zd,项目名称:cs362w16,代码行数:27,代码来源:unittest3.c

示例4: test1

int test1(int seed) 
{
	int i, j;
	int *k = (int*)malloc(sizeof(int)*NUMCARDS);

	int numPlayers = (rand()% 3) + 2;
	int ret = -1;

	struct gameState *G = newGame();
//	struct gameState *Gcpy = newGame();
	//repeat until you get return val 0 in initializeGame, i.e. all kingdom cards are unique

	printf("TEST #1: Kingdom cards random testing\n");
	printf("\t should return 0 if unique; -1 if non-unique\n");
	for(i = 0; i < NUMTRIALS; i++)
	{
		for(j = 0; j < NUMCARDS; j++) {
			k[j] = (rand()%15);
		}
		ret = initializeGame(numPlayers, k, seed, G);
		int cret = cardsAreUnique(k);
		if(cret == 0) {
			ASSERT2(ret, 0, "FAIL when cards are unique");
		}
		else {
			ASSERT2(ret, -1, "FAIL when cards are non-unique");
		}
	}

	printf("PASS\n");
	printf("------------------\n");
	free(G);
	free(k);
}
开发者ID:cr8zd,项目名称:cs362w16,代码行数:34,代码来源:unittest3.c

示例5: perform_transfer

void perform_transfer(urb_t *urb) {
	int direction = urb->direction == IN ? LIBUSB_ENDPOINT_IN : LIBUSB_ENDPOINT_OUT;

	/* Take a care about timings */
	if(urb->timing) {
		int time = urb->timing*pow(10,6);
		usleep(time);
	}

	/* Trigger libusb to perform the transfer */
	int r, bytes_transferred = 0;
	struct libusb_transfer transfer;
	switch(urb->type) {
		case CTRL:
			r = libusb_control_transfer(dev_handle, 
					urb->bmRequestType | direction,
					urb->bRequest,
					urb->wValue,
					urb->wIndex,
					urb->data,
					urb->data_size,
					0);
			ASSERT2(r >= 0, TRANSFER_FAILED_MESSAGE, libusb_error_name(r));
			break;
		case BULK:
			r = libusb_bulk_transfer(dev_handle,
					urb->endpoint | direction,
					urb->data,
					urb->data_size,
					&bytes_transferred,
					0);
			ASSERT2(r == 0, TRANSFER_FAILED_MESSAGE, libusb_error_name(r));
			break;
		case INTR:
			r = libusb_interrupt_transfer(dev_handle,
					urb->endpoint | direction,
					urb->data,
					urb->data_size,
					&bytes_transferred,
					0);
			ASSERT2(r == 0, TRANSFER_FAILED_MESSAGE, libusb_error_name(r));
			break;
		case ISOC:
			libusb_fill_iso_transfer(&transfer,
					dev_handle,
					urb->endpoint | direction,
					urb->data,
					urb->data_size,
					1,
					continue_transfer_cb,
					NULL,
					0);
			libusb_submit_transfer(&transfer);
			ASSERT2(r == 0, TRANSFER_FAILED_MESSAGE, libusb_error_name(r));
			break;
	}
}
开发者ID:rbarraud,项目名称:usbsniff,代码行数:57,代码来源:usb_replay.c

示例6: ASSERT2

void index_set::collect_type2_common_subexpressions() {

	ASSERT2(current.empty(),"recording not finished or not run");
	ASSERT2(type2_cse.empty(),"this function has already been called");

	for (int i=0; i<number_of_constraints(); ++i) {

		check_for_common_subexpressions(i);
	}
}
开发者ID:baharev,项目名称:old_sandbox,代码行数:10,代码来源:index_set.cpp

示例7: ASSERT2

static const char *skip_to_params(const char *input, const struct CmdTemplate *cmdp)
{
	const char *begin = input, *end = input;

	// Skip the ID, and get the command
	if (!get_word(&begin, &end))
		return NULL;
	if (!get_word(&begin, &end))
		return NULL;

	ASSERT2(strlen(cmdp->name) == (size_t)(end-begin), "Invalid command template specified");
	ASSERT2(!strncmp(begin, cmdp->name, end-begin), "Invalid command template specified");

	return end;
}
开发者ID:amdoolittle,项目名称:APRS_Projects,代码行数:15,代码来源:parser.c

示例8: ASSERT

double port_impl::col_val(int i) const {

	ASSERT(i<=M); // X.size() == N

	double val = X.at(i-1);

	const double lb = col_lb(i);

	const double ub = col_ub(i);

	ASSERT2(lb<ub,"lb, ub: "<<lb<<", "<<ub);

	if ((val+1.0e-4 < lb) || (val > ub+1.0e-4)) {

		ASSERT(false);
		//throw numerical_problems();
	}

	if (val < lb) {

		val = lb;
	}
	else if (val > ub) {

		val = ub;
	}

	return val;
}
开发者ID:baharev,项目名称:old_sandbox,代码行数:29,代码来源:port_impl.cpp

示例9: FreeGaussMixModel

void FreeGaussMixModel(GaussMixModel *p_gmmParam,int p_nModelNum)
{
	if (p_gmmParam)
	{
		ASSERT2(p_nModelNum,"Error call FreeGaussMixModel() : p_nModelNum<0!");
		for (int i=0;i<p_nModelNum;i++)
		{
			if (p_gmmParam[i].pGauss)		
			{
				Free(p_gmmParam[i].pfMeanBuf);
				Free(p_gmmParam[i].pfDiagCovBuf);

				Free(p_gmmParam[i].pGauss);

				p_gmmParam[i].pfMeanBuf = NULL;
				p_gmmParam[i].pfDiagCovBuf = NULL;
				p_gmmParam[i].pGauss = NULL;
			}
			Free(p_gmmParam[i].pfWeight);
			p_gmmParam[i].pfWeight = NULL;
		}
		Free(p_gmmParam);
		p_gmmParam = NULL;
	}
}
开发者ID:d-unknown-processor,项目名称:ivectool,代码行数:25,代码来源:OldUbm2NewUbm.cpp

示例10: parseArgs

/**
 * \brief Command arguments parser.
 *
 * Using the format pointed by the argument fmt
 * parses the input string filling the array argv
 * with input parameters of the correct type.
 *
 * \param fmt   Parameters format string.
 * \param input Input string.
 * \param argv  Array filled with parameters.
 *
 * \return False in case of errors, otherwise true.
 */
static bool parseArgs(const char *fmt, const char *input, parms argv[])
{
	const char *begin = input, *end = input;

	while (*fmt)
	{
		// Extract the argument
		if (!get_word(&begin, &end))
			return false;

		switch (*fmt)
		{
			case 'd':
				(*argv++).l = atol(begin);
				break;

			case 's':
				(*argv++).s = begin;
				break;

			default:
				ASSERT2(0, "Unknown format for argument");
				return false;
		}

		++fmt;
	}

	/* check if there are remaining args */
	if (get_word(&begin, &end))
		return false;

	return true;
}
开发者ID:amdoolittle,项目名称:APRS_Projects,代码行数:47,代码来源:parser.c

示例11: ASSERT2

const DoubleArray2D Bratu<T>::solutions() const {

	ASSERT2(n_vars==SIZE,"n_vars: "<<n_vars)

	ASSERT2(SOLS==n_sol,"n_sol: "<<n_sol);

	DoubleArray2D solution_vectors(SOLS);

	for (int i=0; i<SOLS; ++i) {

		const double* const x = sol[i];

		solution_vectors.at(i).assign(x, x + SIZE);
	}

	return solution_vectors;
}
开发者ID:baharev,项目名称:old_sandbox,代码行数:17,代码来源:Bratu.cpp

示例12: load_id

void load_id(FILE *f, const string &s) {
    string s2;
    load(f, s2);
    if (s2 != s) {
        fprintf(stderr, "Error: load_id expected |%s|, received |%s|\n", s.c_str(), s2.c_str());
        ASSERT2(false, "load from file failed: load_id expected matching string");
    }
}
开发者ID:caomw,项目名称:patchtable,代码行数:8,代码来源:patchtable.cpp

示例13: combuf_read

uint8_t combuf_read(const combuf_t combuf, const combuf_pos_t pos)
{
    ASSERT1(CHECK_COMBUF(combuf), "invalid combuf = %d", combuf);
    ASSERT2(pos < PAYLOAD_SIZE(combuf),
            "invalid pos = %hhu ( combuf = %d)", pos, combuf);

    return PAYLOAD_ITEM(combuf, pos);
}
开发者ID:MaxGekk,项目名称:ZigZag,代码行数:8,代码来源:combuf.c

示例14: ASSERT2

int port_impl::find_index_position(int i) const {

	std::vector<int>::const_iterator itr = std::find(ISIMP.begin(), ISIMP.end(), i);

	ASSERT2(itr!=ISIMP.end(),"index not found: "<<i);

	return itr - ISIMP.begin();
}
开发者ID:baharev,项目名称:old_sandbox,代码行数:8,代码来源:port_impl.cpp

示例15: test3c

int test3c(int seed) {
	int ret;
	int numPlayers;
	int curseCount, estateCount, duchyCount, provinceCount, copperCount, silverCount = 40, goldCount = 30;
	struct gameState *G = newGame();
	int *k = getUniqueCards();

	//Test when players are 4
	numPlayers = 4;
	ret = initializeGame(numPlayers, k, seed, G);
	curseCount = G->supplyCount[curse];
	estateCount = G->supplyCount[estate];
	duchyCount = G->supplyCount[duchy];
	provinceCount = G->supplyCount[province];
	copperCount = G->supplyCount[copper];
	silverCount = G->supplyCount[silver];
	goldCount = G->supplyCount[gold];
	ASSERT2(curseCount, 30, "curseCount");
	ASSERT2(estateCount, 12, "estateCount");
	ASSERT2(duchyCount, 12, "duchyCount");
	ASSERT2(provinceCount, 12, "provinceCount");
	ASSERT2(copperCount, (60 - (7 * numPlayers)), "copperCount");
	ASSERT2(silverCount, 40, "silverCount");
	ASSERT2(goldCount, 30, "goldCount");
	free(G);
	free(k);
}
开发者ID:cr8zd,项目名称:cs362w16,代码行数:27,代码来源:unittest3.c


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