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


C++ CU_ASSERT_TRUE函数代码示例

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


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

示例1: test_loop

static void test_loop(int is_epoll)
{
	int res = 0;
	int tfd1 = -1, tfd2 = -1, tfd3 = -1;
	int fd = -1;
	struct test_data data;
	struct pomp_loop *loop = NULL;

	memset(&data, 0, sizeof(data));

	/* Create loop */
	loop = pomp_loop_new();
	CU_ASSERT_PTR_NOT_NULL_FATAL(loop);

	/* Create timers for testing */
	tfd1 = setup_timerfd(100, 500);
	CU_ASSERT_TRUE_FATAL(tfd1 >= 0);
	tfd2 = setup_timerfd(50, 500);
	CU_ASSERT_TRUE_FATAL(tfd2 >= 0);
	tfd3 = setup_timerfd(150, 500);
	CU_ASSERT_TRUE_FATAL(tfd3 >= 0);

	/* Add timer in loop */
	res = pomp_loop_add(loop, tfd1, POMP_FD_EVENT_IN, &timerfd_cb, &data);
	CU_ASSERT_EQUAL(res, 0);

	res = pomp_loop_has_fd(loop, tfd1);
	CU_ASSERT_EQUAL(res, 1);

	res = pomp_loop_has_fd(loop, tfd2);
	CU_ASSERT_EQUAL(res, 0);

	/* Invalid add (already in loop) */
	res = pomp_loop_add(loop, tfd1, POMP_FD_EVENT_IN, &timerfd_cb, &data);
	CU_ASSERT_EQUAL(res, -EEXIST);

	/* Invalid add (NULL param) */
	res = pomp_loop_add(NULL, tfd1, POMP_FD_EVENT_IN, &timerfd_cb, &data);
	CU_ASSERT_EQUAL(res, -EINVAL);
	res = pomp_loop_add(loop, tfd1, POMP_FD_EVENT_IN, NULL, &data);
	CU_ASSERT_EQUAL(res, -EINVAL);

	/* Invalid add (invalid events) */
	res = pomp_loop_add(loop, tfd1, 0, &timerfd_cb, &data);
	CU_ASSERT_EQUAL(res, -EINVAL);

	/* Invalid add (invalid fd) */
	res = pomp_loop_add(loop, -1, POMP_FD_EVENT_IN, &timerfd_cb, &data);
	CU_ASSERT_EQUAL(res, -EINVAL);

	/* Update events */
	res = pomp_loop_update(loop, tfd1, POMP_FD_EVENT_IN | POMP_FD_EVENT_OUT);
	CU_ASSERT_EQUAL(res, 0);

	/* Invalid update (NULL param) */
	res = pomp_loop_update(NULL, tfd1, POMP_FD_EVENT_IN | POMP_FD_EVENT_OUT);
	CU_ASSERT_EQUAL(res, -EINVAL);

	/* Invalid update (invalid events) */
	res = pomp_loop_update(loop, tfd1, 0);
	CU_ASSERT_EQUAL(res, -EINVAL);

	/* Invalid update (invalid fd) */
	res = pomp_loop_update(loop, -1, POMP_FD_EVENT_IN | POMP_FD_EVENT_OUT);
	CU_ASSERT_EQUAL(res, -EINVAL);

	/* Invalid remove (fd not registered) */
	res = pomp_loop_update(loop, 2, POMP_FD_EVENT_IN | POMP_FD_EVENT_OUT);
	CU_ASSERT_EQUAL(res, -ENOENT);

	/* Update again events */
	res = pomp_loop_update(loop, tfd1, POMP_FD_EVENT_IN);
	CU_ASSERT_EQUAL(res, 0);

	/* Add 2nd and 3rd timer in loop */
	res = pomp_loop_add(loop, tfd2, POMP_FD_EVENT_IN, &timerfd_cb, &data);
	CU_ASSERT_EQUAL(res, 0);
	res = pomp_loop_add(loop, tfd3, POMP_FD_EVENT_IN, &timerfd_cb, &data);
	CU_ASSERT_EQUAL(res, 0);

	/* Get loop fd */
	fd = pomp_loop_get_fd(loop);
	CU_ASSERT_TRUE((is_epoll && fd >= 0) || (!is_epoll && fd == -ENOSYS));
	fd = pomp_loop_get_fd(NULL);
	CU_ASSERT_EQUAL(fd, -EINVAL);

	/* Run loop with different timeout first one should have all timers) */
	res = pomp_loop_wait_and_process(loop, 500);
	CU_ASSERT_EQUAL(res, 0);
	res = pomp_loop_wait_and_process(loop, 0);
	CU_ASSERT_TRUE(res == -ETIMEDOUT || res == 0);
	res = pomp_loop_wait_and_process(loop, -1);
	CU_ASSERT_EQUAL(res, 0);

	/* Invalid run (NULL param) */
	res = pomp_loop_wait_and_process(NULL, 0);
	CU_ASSERT_EQUAL(res, -EINVAL);

	/* Invalid destroy (NULL param) */
	res = pomp_loop_destroy(NULL);
//.........这里部分代码省略.........
开发者ID:miniupnp,项目名称:libpomp,代码行数:101,代码来源:pomp_test_loop.c

示例2: test_modesense6_residuals

void
test_modesense6_residuals(void)
{
        struct scsi_task *ms_task = NULL;

        logging(LOG_VERBOSE, LOG_BLANK_LINE);
        logging(LOG_VERBOSE, "Test of MODESENSE6 Residuals");

        logging(LOG_VERBOSE, "MODESENSE6 command should not result in any "
                "residuals");

        
        logging(LOG_VERBOSE, "Try a MODESENSE6 command with 4 bytes of "
                "transfer length and verify that we don't get residuals.");
        MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
                   SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 4,
                   EXPECT_STATUS_GOOD);

        logging(LOG_VERBOSE, "[SUCCESS] All Pages fetched.");

        logging(LOG_VERBOSE, "Verify that we got at most 4 bytes of DATA-IN");
        if (ms_task->datain.size > 4) {
                logging(LOG_NORMAL, "[FAILED] got more than 4 bytes of "
                        "DATA-IN.");
        } else {
                logging(LOG_VERBOSE, "[SUCCESS] <= 4 bytes of DATA-IN "
                        "received.");
        }
        CU_ASSERT_TRUE(ms_task->datain.size <= 4);


        logging(LOG_VERBOSE, "Verify residual overflow flag not set");
        if (ms_task->residual_status == SCSI_RESIDUAL_OVERFLOW) {
                logging(LOG_VERBOSE, "[FAILED] Target set residual "
                        "overflow flag");
        }
        CU_ASSERT_NOT_EQUAL(ms_task->residual_status, SCSI_RESIDUAL_OVERFLOW);



        logging(LOG_VERBOSE, "Try a MODESENSE6 command with 255 bytes of "
                "transfer length and verify that we get residuals if the target returns less than the requested amount of data.");
        scsi_free_scsi_task(ms_task);
        MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
                   SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
                   EXPECT_STATUS_GOOD);
        logging(LOG_VERBOSE, "[SUCCESS] All Pages fetched.");

        if (ms_task->datain.size == 255) {
                logging(LOG_VERBOSE, "We got all 255 bytes of data back "
                        "from the target. Verify that underflow is not set.");

                if (ms_task->residual_status == SCSI_RESIDUAL_UNDERFLOW) {
                        logging(LOG_VERBOSE, "[FAILED] Target set residual "
                                "underflow flag");
                } else {
                        logging(LOG_VERBOSE, "[SUCCESS] Residual underflow "
                                "is not set");
                }
                CU_ASSERT_NOT_EQUAL(ms_task->residual_status,
                                SCSI_RESIDUAL_UNDERFLOW);
        } else {
                logging(LOG_VERBOSE, "We got less than the requested 255 bytes "
                        "from the target. Verify that underflow is set.");

                if (ms_task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
                        logging(LOG_VERBOSE, "[FAILED] Target did not set "
                                "residual underflow flag");
                } else {
                        logging(LOG_VERBOSE, "[SUCCESS] Residual underflow "
                                "is set");
                }
                CU_ASSERT_EQUAL(ms_task->residual_status,
                                SCSI_RESIDUAL_UNDERFLOW);
        }

        scsi_free_scsi_task(ms_task);
}
开发者ID:bonzini,项目名称:libiscsi,代码行数:78,代码来源:test_modesense6_residuals.c

示例3: test_arrayList_isEmpty

void test_arrayList_isEmpty(void) {
	arrayList_clear(list);
	CU_ASSERT_EQUAL(list->size, 0);
	CU_ASSERT_TRUE(arrayList_isEmpty(list));
}
开发者ID:jawi,项目名称:celix,代码行数:5,代码来源:array_list_test.c

示例4: test_event_cb_t

static void test_event_cb_t(struct pomp_ctx *ctx, enum pomp_event event,
		struct pomp_conn *conn, const struct pomp_msg *msg,
		void *userdata)
{
	int fd;
	int res = 0;
	struct test_data *data = userdata;
	const char *eventstr = pomp_event_str(event);
	const struct sockaddr *addr = NULL;
	uint32_t addrlen = 0;
	const struct pomp_cred *cred = NULL;
	int isunix = 0;

	switch (event) {
	case POMP_EVENT_CONNECTED:
		data->connection++;

		/* Invalid get fd (NULL param) */
		fd = pomp_conn_get_fd(NULL);
		CU_ASSERT_EQUAL(fd, -EINVAL);

		fd = pomp_conn_get_fd(conn);
		CU_ASSERT_TRUE(fd >= 0);

		addr = pomp_conn_get_local_addr(conn, &addrlen);
		CU_ASSERT_TRUE(addr != NULL);
		addr = pomp_conn_get_peer_addr(conn, &addrlen);
		CU_ASSERT_TRUE(addr != NULL);
		isunix = addr->sa_family == AF_UNIX;

		/* Invalid get addr (NULL param) */
		addr = pomp_conn_get_local_addr(NULL, &addrlen);
		CU_ASSERT_TRUE(addr == NULL);
		addr = pomp_conn_get_local_addr(conn, NULL);
		CU_ASSERT_TRUE(addr == NULL);
		addr = pomp_conn_get_peer_addr(NULL, &addrlen);
		CU_ASSERT_TRUE(addr == NULL);
		addr = pomp_conn_get_peer_addr(conn, NULL);
		CU_ASSERT_TRUE(addr == NULL);

		if (!isunix) {
			/* Invalid get credentials (bad type or NULL param) */
			cred = pomp_conn_get_peer_cred(conn);
			CU_ASSERT_TRUE(cred == NULL);
			cred = pomp_conn_get_peer_cred(NULL);
			CU_ASSERT_TRUE(cred == NULL);
		} else {
			cred = pomp_conn_get_peer_cred(conn);
			CU_ASSERT_TRUE(cred != NULL);
		}
		break;

	case POMP_EVENT_DISCONNECTED:
		data->disconnection++;
		break;

	case POMP_EVENT_MSG:
		data->msg++;
		if (pomp_msg_get_id(msg) == 1) {
			res = pomp_conn_send(conn, 2, "%s", eventstr);
			CU_ASSERT_EQUAL(res, 0);
		}

		if (data->isdgram) {
			res = pomp_conn_disconnect(conn);
			CU_ASSERT_EQUAL(res, -ENOTCONN);

			/* Internal function invalid arguments checks */
			res = pomp_conn_send_msg_to(NULL, msg, NULL, 0);
			CU_ASSERT_EQUAL(res, -EINVAL);
			res = pomp_conn_send_msg_to(conn, NULL, NULL, 0);
			CU_ASSERT_EQUAL(res, -EINVAL);
		} else {
			/* Internal function invalid arguments checks */
			res = pomp_conn_send_msg(NULL, msg);
			CU_ASSERT_EQUAL(res, -EINVAL);
			res = pomp_conn_send_msg(conn, NULL);
			CU_ASSERT_EQUAL(res, -EINVAL);
		}

		/* Internal function invalid arguments checks */
		res = pomp_ctx_notify_event(NULL, POMP_EVENT_CONNECTED, conn);
		CU_ASSERT_EQUAL(res, -EINVAL);
		res = pomp_ctx_notify_event(ctx, POMP_EVENT_MSG, conn);
		CU_ASSERT_EQUAL(res, -EINVAL);
		res = pomp_ctx_notify_event(ctx, POMP_EVENT_CONNECTED, NULL);
		CU_ASSERT_EQUAL(res, -EINVAL);
		res = pomp_ctx_notify_msg(NULL, conn, msg);
		CU_ASSERT_EQUAL(res, -EINVAL);
		res = pomp_ctx_notify_msg(ctx, NULL, msg);
		CU_ASSERT_EQUAL(res, -EINVAL);
		res = pomp_ctx_notify_msg(ctx, conn, NULL);
		CU_ASSERT_EQUAL(res, -EINVAL);
		break;

	default:
		CU_ASSERT_TRUE_FATAL(0);
		break;
	}
}
开发者ID:zousenming,项目名称:libpomp,代码行数:100,代码来源:pomp_test_ctx.c

示例5: teste_DT_verificaNovaTela_Y

void teste_DT_verificaNovaTela_Y () {
	Tela teste;

	teste = nova_tela();
	CU_ASSERT_TRUE(teste.y);
}
开发者ID:Roffelos,项目名称:Psycho-Tetris,代码行数:6,代码来源:tela_teste.c

示例6: test_linkedlist_addremove

void test_linkedlist_addremove()
{
    CPLinkedListRef list;
    CPLinkedListItemRef item0;
    CPLinkedListItemRef item1;
    CPLinkedListItemRef item2;

    // Add retains/remove releases
    _test_linkedlist_total_item_count = 0;
    list = CPLinkedListCreate(offsetof(CPLinkedListItem, prevItem), offsetof(CPLinkedListItem, nextItem));
    CU_ASSERT(list != NULL);
    item0 = CPLinkedListItemCreate();
    CU_ASSERT(item0 != NULL);
    CU_ASSERT(_test_linkedlist_total_item_count == 1);
    CU_ASSERT_TRUE(CPLinkedListAddItem(list, item0));
    CPRelease(item0);
    CU_ASSERT(_test_linkedlist_total_item_count == 1);
    CPLinkedListRemoveItem(list, CPLinkedListGetHead(list));
    CU_ASSERT(_test_linkedlist_total_item_count == 0);
    CPRelease(list);
    _test_linkedlist_total_item_count = 0;

    // Adding multiple times
    _test_linkedlist_total_item_count = 0;
    list = CPLinkedListCreate(offsetof(CPLinkedListItem, prevItem), offsetof(CPLinkedListItem, nextItem));
    CU_ASSERT(list != NULL);
    item0 = CPLinkedListItemCreate();
    CU_ASSERT(item0 != NULL);
    CU_ASSERT(_test_linkedlist_total_item_count == 1);
    CU_ASSERT_TRUE(CPLinkedListAddItem(list, item0));
    CU_ASSERT_FALSE(CPLinkedListAddItem(list, item0));
    CU_ASSERT(_test_linkedlist_total_item_count == 1);
    CPLinkedListRemoveItem(list, item0);
    CPRelease(item0);
    CU_ASSERT(_test_linkedlist_total_item_count == 0);
    CPRelease(list);
    _test_linkedlist_total_item_count = 0;

    // Removing multiple times
    _test_linkedlist_total_item_count = 0;
    list = CPLinkedListCreate(offsetof(CPLinkedListItem, prevItem), offsetof(CPLinkedListItem, nextItem));
    CU_ASSERT(list != NULL);
    item0 = CPLinkedListItemCreate();
    CU_ASSERT(item0 != NULL);
    CU_ASSERT(_test_linkedlist_total_item_count == 1);
    CU_ASSERT_TRUE(CPLinkedListAddItem(list, item0));
    CPLinkedListRemoveItem(list, item0);
    CPLinkedListRemoveItem(list, item0);
    CPRelease(item0);
    CU_ASSERT(_test_linkedlist_total_item_count == 0);
    CPRelease(list);
    _test_linkedlist_total_item_count = 0;

    // Remove all
    _test_linkedlist_total_item_count = 0;
    list = CPLinkedListCreate(offsetof(CPLinkedListItem, prevItem), offsetof(CPLinkedListItem, nextItem));
    CU_ASSERT(list != NULL);
    item0 = CPLinkedListItemCreate();
    CU_ASSERT(item0 != NULL);
    CU_ASSERT(_test_linkedlist_total_item_count == 1);
    item1 = CPLinkedListItemCreate();
    CU_ASSERT(item1 != NULL);
    CU_ASSERT(_test_linkedlist_total_item_count == 2);
    item2 = CPLinkedListItemCreate();
    CU_ASSERT(item2 != NULL);
    CU_ASSERT(_test_linkedlist_total_item_count == 3);
    CU_ASSERT_TRUE(CPLinkedListAddItem(list, item0));
    CU_ASSERT_TRUE(CPLinkedListAddItem(list, item1));
    CU_ASSERT_TRUE(CPLinkedListAddItem(list, item2));
    CU_ASSERT(CPLinkedListGetCount(list) == 3);
    CU_ASSERT(CPLinkedListGetHead(list) != NULL);
    CU_ASSERT(CPLinkedListGetTail(list) != NULL);
    CPLinkedListRemoveAllItems(list);
    CU_ASSERT(CPLinkedListGetCount(list) == 0);
    CU_ASSERT(CPLinkedListGetHead(list) == NULL);
    CU_ASSERT(CPLinkedListGetTail(list) == NULL);
    CPRelease(item2);
    CPRelease(item1);
    CPRelease(item0);
    CU_ASSERT(_test_linkedlist_total_item_count == 0);
    CPRelease(list);
    _test_linkedlist_total_item_count = 0;

    // Remove all releases
    _test_linkedlist_total_item_count = 0;
    list = CPLinkedListCreate(offsetof(CPLinkedListItem, prevItem), offsetof(CPLinkedListItem, nextItem));
    CU_ASSERT(list != NULL);
    item0 = CPLinkedListItemCreate();
    CU_ASSERT(item0 != NULL);
    CU_ASSERT(_test_linkedlist_total_item_count == 1);
    item1 = CPLinkedListItemCreate();
    CU_ASSERT(item1 != NULL);
    CU_ASSERT(_test_linkedlist_total_item_count == 2);
    item2 = CPLinkedListItemCreate();
    CU_ASSERT(item2 != NULL);
    CU_ASSERT(_test_linkedlist_total_item_count == 3);
    CU_ASSERT_TRUE(CPLinkedListAddItem(list, item0));
    CU_ASSERT_TRUE(CPLinkedListAddItem(list, item1));
    CU_ASSERT_TRUE(CPLinkedListAddItem(list, item2));
    CU_ASSERT(CPLinkedListGetCount(list) == 3);
//.........这里部分代码省略.........
开发者ID:benvanik,项目名称:CorePlatform,代码行数:101,代码来源:test_linkedlist.c

示例7: test_prin_report_caps_simple

void
test_prin_report_caps_simple(void)
{
	int ret = 0;
	const unsigned long long key = rand_key();
	struct scsi_task *tsk;
	struct scsi_persistent_reserve_in_report_capabilities *rcaps;
	struct test_prin_report_caps_types *type;

	CHECK_FOR_DATALOSS;

	logging(LOG_VERBOSE, LOG_BLANK_LINE);
	logging(LOG_VERBOSE,
		"Test Persistent Reserve In REPORT CAPABILITIES works.");

	/* register our reservation key with the target */
	ret = prout_register_and_ignore(sd, key);
	if (ret == -2) {
		logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
		CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
		return;
	}
	CU_ASSERT_EQUAL(ret, 0);

	ret = prin_report_caps(sd, &tsk, &rcaps);
	CU_ASSERT_EQUAL(ret, 0);

	logging(LOG_VERBOSE,
		"Checking PERSISTENT RESERVE IN REPORT CAPABILITIES fields.");
	CU_ASSERT_EQUAL(rcaps->length, 8);
	CU_ASSERT_TRUE(rcaps->allow_commands <= 5);
	CU_ASSERT_EQUAL(rcaps->persistent_reservation_type_mask
			& ~SCSI_PR_TYPE_MASK_ALL, 0);

	for (type = &report_caps_types_array[0]; type->mask != 0; type++) {
		if (!(rcaps->persistent_reservation_type_mask & type->mask)) {
			logging(LOG_NORMAL,
				"PERSISTENT RESERVE op 0x%x not supported",
				type->op);
			continue;
		}

		logging(LOG_VERBOSE,
			"PERSISTENT RESERVE OUT op 0x%x supported, testing",
			type->op);

		/* reserve the target */
		ret = prout_reserve(sd, key, type->op);
		CU_ASSERT_EQUAL(ret, 0);

		/* verify target reservation */
		ret = prin_verify_reserved_as(sd,
				pr_type_is_all_registrants(type->op) ? 0 : key,
				type->op);
		CU_ASSERT_EQUAL(0, ret);

		/* release the target */
		ret = prout_release(sd, key, type->op);
		CU_ASSERT_EQUAL(ret, 0);
	}

	scsi_free_scsi_task(tsk);
	rcaps = NULL;	/* freed with tsk */

	/* drop registration */
	ret = prout_register_key(sd, 0, key);
	CU_ASSERT_EQUAL(ret, 0);
}
开发者ID:daodewang,项目名称:libiscsi,代码行数:68,代码来源:test_prin_report_caps.c

示例8: stack_some_pieces

void stack_some_pieces()
{
    int numberOfRows = 20;
    int numberOfColumns = 10;
    int delay = 500;
    int imove;
    TrnGame* game = trn_game_new(numberOfRows, numberOfColumns, delay);
    
    // TrnPiece 0. While the piece is falling:
    // Rotate it 3 times.
    for (imove = 0; imove < 3; imove++) {
        CU_ASSERT_TRUE( trn_game_try_to_move_down(game) );
        CU_ASSERT_TRUE( trn_game_try_to_rotate_clockwise(game) );
    }

    // Move piece to left.
    CU_ASSERT_TRUE( trn_game_try_to_move_down(game) );
    CU_ASSERT_TRUE( trn_game_try_to_move_left(game) );
    // Reach bottom.
    while (true) {
        if (! trn_game_try_to_move_down(game))
            break;
    }
    
    // TrnPiece 1. While the piece is falling:
    // Rotate it 1 times.
    CU_ASSERT_TRUE( trn_game_try_to_move_down(game) );
    CU_ASSERT_TRUE( trn_game_try_to_rotate_clockwise(game) );

    // Move piece to left.
    for (imove = 0; imove < 4; imove++) {
        CU_ASSERT_TRUE( trn_game_try_to_move_down(game) );
        CU_ASSERT_TRUE( trn_game_try_to_move_left(game) );
    }
    
    // Reach bottom.
    while (true) {
        if (! trn_game_try_to_move_down(game))
            break;
    }
    
    // TrnPiece 2. While the piece is falling:
    // Rotate it 1 times.
    CU_ASSERT_TRUE( trn_game_try_to_move_down(game) );
    CU_ASSERT_TRUE( trn_game_try_to_rotate_clockwise(game) );
    // Move piece to left.
    for (imove = 0; imove < 2; imove++) {
        CU_ASSERT_TRUE( trn_game_try_to_move_down(game) );
        CU_ASSERT_TRUE( trn_game_try_to_move_left(game) );
    }
    // Reach bottom.
    while (true) {
        if (! trn_game_try_to_move_down(game))
            break;
    }
    
    // TrnPiece 3. While the piece is falling:
    // Rotate it 3 times.
    for (imove = 0; imove < 3; imove++) {
        CU_ASSERT_TRUE( trn_game_try_to_move_down(game) );
        CU_ASSERT_TRUE( trn_game_try_to_rotate_clockwise(game) );
    }
    // Move piece to left.
    for (imove = 0; imove < 3; imove++) {
        CU_ASSERT_TRUE( trn_game_try_to_move_down(game) );
        CU_ASSERT_TRUE( trn_game_try_to_move_left(game) );
    }
    // Reach bottom.
    while (true) {
        if (! trn_game_try_to_move_down(game))
            break;
    }

    TrnGrid* expected_grid = trn_grid_new(numberOfRows, numberOfColumns);
    int rowIndex;
    int columnIndex;
    TrnPositionInGrid pos;

    // Expected expected_grid type for pieces 0 and 2
    for (rowIndex = numberOfRows-4 ; rowIndex < numberOfRows ; rowIndex++) {
        pos.rowIndex = rowIndex;
        for (columnIndex = 2 ; columnIndex < 4 ; columnIndex++) {
            pos.columnIndex = columnIndex;
            trn_grid_set_cell(expected_grid, pos, TRN_TETROMINO_J);
        }
    }

    // Expected expected_grid type for pieces 1 and 3
    for (rowIndex = numberOfRows-4 ; rowIndex < numberOfRows ; rowIndex++) {
        pos.rowIndex = rowIndex;
        for (columnIndex = 0 ; columnIndex < 2 ; columnIndex++) {
            pos.columnIndex = columnIndex;
            trn_grid_set_cell(expected_grid, pos, TRN_TETROMINO_L);
        }
    }

    // Expected next piece
    pos.rowIndex = 0;
    pos.columnIndex = 3;
    trn_grid_set_cell(expected_grid, pos, TRN_TETROMINO_J);
//.........这里部分代码省略.........
开发者ID:sed-pro-inria,项目名称:tetrinria,代码行数:101,代码来源:test_tetrinria_core.c

示例9: Testle_sms_ReceivedList

//--------------------------------------------------------------------------------------------------
void Testle_sms_ReceivedList()
{
    le_result_t              res;
    le_sms_MsgRef_t         myMsg;
    le_sms_MsgRef_t         lMsg1, lMsg2;
    le_sms_MsgListRef_t     receivedList;
    le_sms_Status_t         mystatus;

    myMsg = le_sms_Create();
    CU_ASSERT_PTR_NOT_NULL(myMsg);

    res=le_sms_SetDestination(myMsg, DEST_TEST_PATTERN);
    CU_ASSERT_EQUAL(res, LE_OK);

    res=le_sms_SetText(myMsg, TEXT_TEST_PATTERN);
    CU_ASSERT_EQUAL(res, LE_OK);

    res=le_sms_Send(myMsg);
    CU_ASSERT_NOT_EQUAL(res, LE_FAULT);
    CU_ASSERT_NOT_EQUAL(res, LE_FORMAT_ERROR);

    res=le_sms_Send(myMsg);
    CU_ASSERT_NOT_EQUAL(res, LE_FAULT);
    CU_ASSERT_NOT_EQUAL(res, LE_FORMAT_ERROR);
    if (res == LE_OK)
    {
        uint32_t i=0;

        fprintf(stderr, "\nPlease ensure that the device has received at least 2 messages, then press enter\n");
        while ( getchar() != '\n' );

        if ((res == LE_OK) && (i<10))
        {
            // List Received messages
            receivedList=le_sms_CreateRxMsgList();
            CU_ASSERT_PTR_NOT_NULL(receivedList);

            lMsg1=le_sms_GetFirst(receivedList);
            CU_ASSERT_PTR_NOT_NULL(lMsg1);
            if (lMsg1 != NULL)
            {
                mystatus=le_sms_GetStatus(lMsg1);
                CU_ASSERT_TRUE((mystatus==LE_SMS_RX_READ)||(mystatus==LE_SMS_RX_UNREAD));
                LE_INFO("-TEST- Delete Rx message 1.%p", lMsg1);
                le_sms_Delete(lMsg1);
            }

            lMsg2=le_sms_GetNext(receivedList);
            CU_ASSERT_PTR_NOT_NULL(lMsg2);
            if (lMsg2 != NULL)
            {
                mystatus=le_sms_GetStatus(lMsg2);
                CU_ASSERT_TRUE((mystatus==LE_SMS_RX_READ)||(mystatus==LE_SMS_RX_UNREAD));
                LE_INFO("-TEST- Delete Rx message 2.%p", lMsg2);
                le_sms_Delete(lMsg2);
            }

            LE_INFO("-TEST- Delete the ReceivedList");
            le_sms_DeleteList(receivedList);
        }
        else
        {
            LE_ERROR("-TEST- Unable to complete Testle_sms_ReceivedList Test");
        }
    }
    else
    {
        LE_ERROR("-TEST- Unable to complete Testle_sms_ReceivedList Test");
    }

    // Delete sent message
    le_sms_Delete(myMsg);
}
开发者ID:madsdore,项目名称:legato-af,代码行数:74,代码来源:le_smsTest.c

示例10: presence_information

static void presence_information(void) {
	const char *bike_description = "Riding my bike";
	const char *vacation_note = "I'm on vacation until July 4th";
	const char *vacation_lang = "en";
	const char *contact = "sip:[email protected]";
	LinphoneCoreManager *marie = presence_linphone_core_manager_new("marie");
	LinphoneCoreManager *pauline = presence_linphone_core_manager_new("pauline");
	LinphonePresenceModel *presence;
	LinphonePresenceActivity *activity = NULL;
	LinphonePresenceNote *note = NULL;
	const char *description = NULL;
	const char *note_content = NULL;
	char *contact2;
	time_t current_timestamp, presence_timestamp;

	CU_ASSERT_TRUE(subscribe_to_callee_presence(marie, pauline));

	/* Presence activity without description. */
	presence = linphone_presence_model_new_with_activity(LinphonePresenceActivityDinner, NULL);
	linphone_core_set_presence_model(pauline->lc, presence);
	wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivityDinner,1);
	CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePresenceActivityDinner, 1);
	activity = linphone_presence_model_get_activity(marie->stat.last_received_presence);
	CU_ASSERT_PTR_NOT_NULL(activity);
	CU_ASSERT_EQUAL(linphone_presence_activity_get_type(activity), LinphonePresenceActivityDinner);
	description = linphone_presence_activity_get_description(activity);
	CU_ASSERT_PTR_NULL(description);

	/* Presence activity with description. */
	presence = linphone_presence_model_new_with_activity(LinphonePresenceActivitySteering, bike_description);
	linphone_core_set_presence_model(pauline->lc, presence);
	wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivitySteering,1);
	CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePresenceActivitySteering, 1);
	activity = linphone_presence_model_get_activity(marie->stat.last_received_presence);
	CU_ASSERT_PTR_NOT_NULL(activity);
	CU_ASSERT_EQUAL(linphone_presence_activity_get_type(activity), LinphonePresenceActivitySteering);
	description = linphone_presence_activity_get_description(activity);
	CU_ASSERT_PTR_NOT_NULL(description);
	if (description != NULL) CU_ASSERT_EQUAL(strcmp(description, bike_description), 0);

	/* Presence activity with description and note. */
	presence = linphone_presence_model_new_with_activity_and_note(LinphonePresenceActivityVacation, NULL, vacation_note, vacation_lang);
	linphone_core_set_presence_model(pauline->lc, presence);
	wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivityVacation,1);
	CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePresenceActivityVacation, 1);
	activity = linphone_presence_model_get_activity(marie->stat.last_received_presence);
	CU_ASSERT_PTR_NOT_NULL(activity);
	CU_ASSERT_EQUAL(linphone_presence_activity_get_type(activity), LinphonePresenceActivityVacation);
	description = linphone_presence_activity_get_description(activity);
	CU_ASSERT_PTR_NULL(description);
	note = linphone_presence_model_get_note(marie->stat.last_received_presence, NULL);
	CU_ASSERT_PTR_NOT_NULL(note);
	if (note != NULL) {
		note_content = linphone_presence_note_get_content(note);
		CU_ASSERT_PTR_NOT_NULL(note_content);
		if (note_content != NULL) {
			CU_ASSERT_EQUAL(strcmp(note_content, vacation_note), 0);
		}
	}

	/* Presence contact. */
	presence = linphone_presence_model_new_with_activity(LinphonePresenceActivityOnThePhone, NULL);
	linphone_presence_model_set_contact(presence, contact);
	linphone_core_set_presence_model(pauline->lc, presence);
	wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivityOnThePhone,1);
	CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePresenceActivityOnThePhone, 1);
	contact2 = linphone_presence_model_get_contact(presence);
	CU_ASSERT_PTR_NOT_NULL(contact2);
	if (contact2 != NULL) {
		CU_ASSERT_EQUAL(strcmp(contact, contact2), 0);
		ms_free(contact2);
	}

	/* Presence timestamp. */
	current_timestamp = ms_time(NULL);
	presence = linphone_presence_model_new_with_activity(LinphonePresenceActivityShopping, NULL);
	linphone_core_set_presence_model(pauline->lc, presence);
	wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivityShopping,1);
	CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePresenceActivityShopping, 1);
	presence_timestamp = linphone_presence_model_get_timestamp(presence);
	CU_ASSERT_TRUE(presence_timestamp >= current_timestamp);

	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline);
}
开发者ID:Aditya-Jadoun,项目名称:linphone,代码行数:85,代码来源:presence_tester.c

示例11: TestGridCanSetCellsWithPiece

void TestGridCanSetCellsWithPiece()
{
    /* Reminder on tetromino_srs_i at TRN_ANGLE_0 and TRN_ANGLE_90:

    T---+---+---+---+
    |   |   |  9|   |   T: topLeftCorner position in grid
    +---+---+---+---+   0: tetromino cells a TRN_ANGLE_0
    | 0 | 0 | 01| 0 |   9: tetromino cells a TRN_ANGLE_90
    +---+---+---+---+
    |   |   |  9|   |
    +---+---+---+---+
    |   |   |  9|   |
    +---+---+---+---+
    */

    // Create a grid.
    int numberOfRows = 10;
    int numberOfColumns = 10;
    TrnGrid* grid = trn_grid_new(numberOfRows, numberOfColumns);

    // For now, the grid has only void cells.

    // Ok, in grid and void.
    TrnPiece piece0 = trn_piece_create(TRN_TETROMINO_I,0,0,TRN_ANGLE_0);
    CU_ASSERT_TRUE( trn_grid_can_set_cells_with_piece(grid, &piece0) )

    // Ok, still in grid (in the first row).
    TrnPiece piece1 = trn_piece_create(TRN_TETROMINO_I,-1,0,TRN_ANGLE_0);
    CU_ASSERT_TRUE( trn_grid_can_set_cells_with_piece(grid, &piece1) )

    // No more in grid.
    TrnPiece piece2 = trn_piece_create(TRN_TETROMINO_I,-2,0,TRN_ANGLE_0);
    CU_ASSERT_FALSE( trn_grid_can_set_cells_with_piece(grid, &piece2) )

    // Ok, in grid and void.
    TrnPiece piece3 = trn_piece_create(TRN_TETROMINO_I,5,0,TRN_ANGLE_90);
    CU_ASSERT_TRUE( trn_grid_can_set_cells_with_piece(grid, &piece3) )

    // Ok, still in grid (in the first column).
    TrnPiece piece4 = trn_piece_create(TRN_TETROMINO_I,5,-2,TRN_ANGLE_90);
    CU_ASSERT_TRUE( trn_grid_can_set_cells_with_piece(grid, &piece4) )

    // No more in grid.
    TrnPiece piece5 = trn_piece_create(TRN_TETROMINO_I,5,-3,TRN_ANGLE_90);
    CU_ASSERT_FALSE( trn_grid_can_set_cells_with_piece(grid, &piece5) )

    // Now, fill the last grid row with non-void tetrominos.
    TrnPositionInGrid pos;
    int columnIndex;
    pos.rowIndex = numberOfRows-1 ;
    for (columnIndex = 0 ; columnIndex < grid->numberOfColumns ; columnIndex++) {
        pos.columnIndex = columnIndex;
        trn_grid_set_cell(grid, pos, TRN_TETROMINO_I);
    }

    // Ok, in grid and void.
    TrnPiece piece6 = trn_piece_create(TRN_TETROMINO_I,0,0,TRN_ANGLE_90);
    CU_ASSERT_TRUE( trn_grid_can_set_cells_with_piece(grid, &piece6) )

    // Still in grid and void, just above the non-void row.
    TrnPiece piece7 = 
		trn_piece_create(TRN_TETROMINO_I,numberOfRows-5,0,TRN_ANGLE_90);
    CU_ASSERT_TRUE( trn_grid_can_set_cells_with_piece(grid, &piece7) )

    // In grid, but last cell of piece overlap a non-void cell of the grid.
    TrnPiece piece8 = 
		trn_piece_create(TRN_TETROMINO_I,numberOfRows-4,0,TRN_ANGLE_90);
    CU_ASSERT_FALSE( trn_grid_can_set_cells_with_piece(grid, &piece8) )
}
开发者ID:sed-pro-inria,项目名称:tetrinria,代码行数:69,代码来源:test_tetrinria_core.c

示例12: teste_DT_Novo_Bloco_Y

void teste_DT_Novo_Bloco_Y(void)
{
	Bloco resultado;
	resultado = novo_bloco(2,3, INVISIVEL);
	CU_ASSERT_TRUE (resultado.y == 3);
}
开发者ID:pannunzio,项目名称:Psycho-Tetris,代码行数:6,代码来源:teste_bloco.c

示例13: teste_DT_Novo_Bloco_Tipo_Quadrado

void teste_DT_Novo_Bloco_Tipo_Quadrado(void)
{
	Bloco resultado;
	resultado = novo_bloco(2,3, QUADRADO);
	CU_ASSERT_TRUE (resultado.tipo == QUADRADO);
}
开发者ID:pannunzio,项目名称:Psycho-Tetris,代码行数:6,代码来源:teste_bloco.c

示例14: teste_DT_Novo_Bloco_Tipo_Invisivel

void teste_DT_Novo_Bloco_Tipo_Invisivel(void)
{
	Bloco resultado;
	resultado = novo_bloco(2,3, INVISIVEL);
	CU_ASSERT_TRUE (resultado.tipo == INVISIVEL);
}
开发者ID:pannunzio,项目名称:Psycho-Tetris,代码行数:6,代码来源:teste_bloco.c

示例15: teste_DT_ProximaLetra_Z

/* Teste letra maiuscula */
void teste_DT_ProximaLetra_Z(void) {
	char resultado;
	resultado = ProximaLetra('Z');
	CU_ASSERT_TRUE( resultado == 'A' );
}
开发者ID:daniloax,项目名称:lic,代码行数:6,代码来源:Exemplo_teste.c


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