當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。