?? test_comms.c
字號:
/*************************************************************************** * Desc: Tests for the comms device * Author: Andrew Howard * Date: 23 May 2002 # CVS: $Id: test_comms.c,v 1.3.4.2 2003/05/23 21:23:43 inspectorg Exp $ **************************************************************************/#include "test.h"#include "playerc.h"// Basic comms device testint test_comms(playerc_client_t *client, int index){ int i; char msg[128]; void *rdevice; playerc_comms_t *comms; printf("device [comms] index [%d]\n", index); TEST("changing data mode to PUSH_ALL"); if (playerc_client_datamode(client, PLAYER_DATAMODE_PUSH_ALL) != 0) { FAIL(); return -1; } PASS(); comms = playerc_comms_create(client, index); TEST("subscribing (read/write)"); if (playerc_comms_subscribe(comms, PLAYER_ALL_MODE) != 0) { FAIL(); return -1; } PASS(); for (i = 0; i < 10; i++) { TEST1("sending comms message [%d]", i); snprintf(msg, sizeof(msg), "this is message (%d)", i); if (playerc_comms_send(comms, msg, strlen(msg) + 1) != 0) FAIL(); else PASS(); } for (i = 0; i < 10; i++) { TEST1("reading data (attempt %d)", i); do rdevice = playerc_client_read(client); while (rdevice == client); if (rdevice == comms) { PASS(); if (comms->msg) printf("recv : %d [%s]\n", comms->msg_len, comms->msg); } else FAIL(); } TEST("unsubscribing"); if (playerc_comms_unsubscribe(comms) != 0) { FAIL(); return -1; } PASS(); playerc_comms_destroy(comms); TEST("changing data mode to PUSH_NEW"); if (playerc_client_datamode(client, PLAYER_DATAMODE_PUSH_NEW) != 0) { FAIL(); return -1; } PASS(); return 0;}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -