本文整理汇总了C++中TEST_ASSERT_EQUAL_INT函数的典型用法代码示例。如果您正苦于以下问题:C++ TEST_ASSERT_EQUAL_INT函数的具体用法?C++ TEST_ASSERT_EQUAL_INT怎么用?C++ TEST_ASSERT_EQUAL_INT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TEST_ASSERT_EQUAL_INT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_nanocoap__get_path_trailing_slash
/*
* Builds on get_req test, to test path with trailing slash.
*/
static void test_nanocoap__get_path_trailing_slash(void)
{
uint8_t buf[_BUF_SIZE];
coap_pkt_t pkt;
uint16_t msgid = 0xABCD;
uint8_t token[2] = {0xDA, 0xEC};
char path[] = "/time/";
size_t uri_opt_len = 6;
size_t len = coap_build_hdr((coap_hdr_t *)&buf[0], COAP_TYPE_NON,
&token[0], 2, COAP_METHOD_GET, msgid);
coap_pkt_init(&pkt, &buf[0], sizeof(buf), len);
len = coap_opt_add_string(&pkt, COAP_OPT_URI_PATH, &path[0], '/');
TEST_ASSERT_EQUAL_INT(uri_opt_len, len);
char uri[10] = {0};
coap_get_uri_path(&pkt, (uint8_t *)&uri[0]);
TEST_ASSERT_EQUAL_STRING((char *)path, (char *)uri);
}
示例2: test_netdev_dummy_add_cb_successful
static void test_netdev_dummy_add_cb_successful(void)
{
char src[] = TEST_STRING64;
size_t src_len = UNITTESTS_NETDEV_DUMMY_MAX_ADDR_LEN;
char dest[] = TEST_STRING64;
size_t dest_len = UNITTESTS_NETDEV_DUMMY_MAX_ADDR_LEN;
char data[] = TEST_STRING8;
#if UNITTESTS_NETDEV_DUMMY_MAX_PACKET < 8
size_t data_len = UNITTESTS_NETDEV_DUMMY_MAX_PACKET;
#else
size_t data_len = 8;
#endif
TEST_ASSERT_EQUAL_INT(0, dev->driver->add_receive_data_callback(dev,
_fill_received));
TEST_ASSERT_EQUAL_INT(0, unittest_netdev_dummy_fire_rcv_event(dev, src,
src_len, dest, dest_len, data, data_len));
TEST_ASSERT_EQUAL_INT(src_len, received_src_len);
TEST_ASSERT_EQUAL_INT(0, memcmp(received_src, src, src_len));
TEST_ASSERT_EQUAL_INT(dest_len, received_dst_len);
TEST_ASSERT_EQUAL_INT(0, memcmp(received_dst, dest, dest_len));
TEST_ASSERT_EQUAL_INT(data_len, received_data_len);
TEST_ASSERT_EQUAL_INT(0, memcmp(received_data, data, data_len));
}
示例3: test_add_fd_with_pending_failing_connect
void test_add_fd_with_pending_failing_connect ()
{
zmq::thread_ctx_t thread_ctx;
zmq::poller_t poller (thread_ctx);
zmq::fd_t bind_socket = socket (AF_INET, SOCK_STREAM, 0);
sockaddr_in addr = {0};
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
addr.sin_port = 0;
TEST_ASSERT_EQUAL_INT (0, bind (bind_socket,
reinterpret_cast<const sockaddr *> (&addr),
sizeof (addr)));
int addr_len = static_cast<int> (sizeof (addr));
TEST_ASSERT_EQUAL_INT (0, getsockname (bind_socket,
reinterpret_cast<sockaddr *> (&addr),
&addr_len));
zmq::fd_t connect_socket = socket (AF_INET, SOCK_STREAM, 0);
zmq::unblock_socket (connect_socket);
TEST_ASSERT_EQUAL_INT (
-1, connect (connect_socket, reinterpret_cast<const sockaddr *> (&addr),
sizeof (addr)));
TEST_ASSERT_EQUAL_INT (WSAEWOULDBLOCK, WSAGetLastError ());
test_events_t events (connect_socket, poller);
zmq::poller_t::handle_t handle = poller.add_fd (connect_socket, &events);
events.set_handle (handle);
poller.set_pollin (handle);
poller.start ();
wait_in_events (events);
int value;
int value_len = sizeof (value);
TEST_ASSERT_EQUAL_INT (0, getsockopt (connect_socket, SOL_SOCKET, SO_ERROR,
reinterpret_cast<char *> (&value),
&value_len));
TEST_ASSERT_EQUAL_INT (WSAECONNREFUSED, value);
// required cleanup
close (connect_socket);
close (bind_socket);
}
示例4: test_nanocoap__get_max_path
/*
* Builds on get_req test, to test max length path.
*/
static void test_nanocoap__get_max_path(void)
{
uint8_t buf[128];
coap_pkt_t pkt;
uint16_t msgid = 0xABCD;
uint8_t token[2] = {0xDA, 0xEC};
char path[] = "/23456789012345678901234567890123456789012345678901234567890123";
/* includes extra byte for option length > 12 */
size_t uri_opt_len = 64;
size_t len = coap_build_hdr((coap_hdr_t *)&buf[0], COAP_TYPE_NON,
&token[0], 2, COAP_METHOD_GET, msgid);
coap_pkt_init(&pkt, &buf[0], sizeof(buf), len);
len = coap_opt_add_string(&pkt, COAP_OPT_URI_PATH, &path[0], '/');
TEST_ASSERT_EQUAL_INT(uri_opt_len, len);
char uri[NANOCOAP_URI_MAX] = {0};
coap_get_uri(&pkt, (uint8_t *)&uri[0]);
TEST_ASSERT_EQUAL_STRING((char *)path, (char *)uri);
}
示例5: test_defaults
int test_defaults (int send_hwm_, int msg_cnt_)
{
// Set up bind socket
void *pub_socket = test_context_socket (ZMQ_PUB);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (pub_socket, "inproc://a"));
// Set up connect socket
void *sub_socket = test_context_socket (ZMQ_SUB);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sub_socket, "inproc://a"));
//set a hwm on publisher
TEST_ASSERT_SUCCESS_ERRNO (
zmq_setsockopt (pub_socket, ZMQ_SNDHWM, &send_hwm_, sizeof (send_hwm_)));
TEST_ASSERT_SUCCESS_ERRNO (
zmq_setsockopt (sub_socket, ZMQ_SUBSCRIBE, 0, 0));
// Send until we block
int send_count = 0;
while (send_count < msg_cnt_
&& zmq_send (pub_socket, NULL, 0, ZMQ_DONTWAIT) == 0)
++send_count;
msleep (SETTLE_TIME);
// Now receive all sent messages
int recv_count = 0;
while (0 == zmq_recv (sub_socket, NULL, 0, ZMQ_DONTWAIT)) {
++recv_count;
}
TEST_ASSERT_EQUAL_INT (send_hwm_, recv_count);
// Clean up
test_context_socket_close (sub_socket);
test_context_socket_close (pub_socket);
return recv_count;
}
示例6: test_map_indefinite
static void test_map_indefinite(void)
{
{
/* serialization */
TEST_ASSERT(cbor_serialize_map_indefinite(&stream));
TEST_ASSERT(cbor_serialize_int(&stream, 1));
TEST_ASSERT(cbor_serialize_byte_string(&stream, "1"));
TEST_ASSERT(cbor_serialize_int(&stream, 2));
TEST_ASSERT(cbor_serialize_byte_string(&stream, "2"));
TEST_ASSERT(cbor_write_break(&stream));
unsigned char data[] = {0xbf,
0x01, 0x41, 0x31, /* kv-pair 1 */
0x02, 0x41, 0x32, /* kv-pair 2 */
0xff
};
CBOR_CHECK_SERIALIZED(stream, data, sizeof(data));
/* deserialization */
size_t offset = cbor_deserialize_map_indefinite(&stream, 0);
int count = 0;
while (!cbor_at_break(&stream, offset)) {
int key;
char value[16];
size_t read_bytes;
offset += read_bytes = cbor_deserialize_int(&stream, offset, &key);
TEST_ASSERT(read_bytes);
offset += read_bytes = cbor_deserialize_byte_string(&stream, offset,
value, sizeof(value));
TEST_ASSERT(read_bytes);
++count;
}
TEST_ASSERT_EQUAL_INT(2, count);
TEST_ASSERT(cbor_at_end(&stream, offset));
}
}
示例7: TEST
TEST(NDSlist, listFlush_nonEmpty) {
TEST_ASSERT_EQUAL_INT(0, nds_list_size(list));
nds_list_insert_head(list, (nds_element_t) 1);
nds_list_insert_head(list, (nds_element_t) 2);
nds_list_insert_head(list, (nds_element_t) 3);
TEST_ASSERT_EQUAL_INT(3, nds_list_size(list));
nds_list_flush(list);
TEST_ASSERT_EQUAL_INT(0, nds_list_size(list));
TEST_ASSERT_NULL(nds_list_get_head(list));
TEST_ASSERT_NULL(nds_list_get_tail(list));
nds_list_insert_head(list, (nds_element_t) 1);
nds_list_insert_tail(list, (nds_element_t) 2);
TEST_ASSERT_EQUAL_INT(2, nds_list_size(list));
TEST_ASSERT_EQUAL_INT(1, nds_list_get_head(list));
TEST_ASSERT_EQUAL_INT(2, nds_list_get_tail(list));
nds_list_flush(list);
TEST_ASSERT_EQUAL_INT(0, nds_list_size(list));
TEST_ASSERT_NULL(nds_list_get_head(list));
TEST_ASSERT_NULL(nds_list_get_tail(list));
}
示例8: TEST
TEST(UniqueMap, MapPutUnique)
{
const int A = 0;
const int B = 4;
struct UniqueMap* map = create_unique_map(A, B);
int values[] = {1,2,3};
int k[3];
k[0] = map_put_unique(map, &values[0]);
TEST_ASSERT_TRUE(k[0] > A && k[0] < B);
k[1] = map_put_unique(map, &values[1]);
TEST_ASSERT_TRUE(k[1] > A && k[1] < B);
TEST_ASSERT_NOT_EQUAL(k[0], k[1]);
k[2] = map_put_unique(map, &values[2]);
TEST_ASSERT_TRUE(k[2] > A && k[2] < B);
TEST_ASSERT_NOT_EQUAL(k[0], k[2]);
TEST_ASSERT_NOT_EQUAL(k[1], k[2]);
TEST_ASSERT_EQUAL_INT(0, map_put_unique(map, &values[2]));
destroy_unique_map(map);
}
示例9: TEST
TEST(api_bignum, capi_truncate_div__4)
{
ScmObj bn1 = SCM_OBJ_INIT, bn2 = SCM_OBJ_INIT;
ScmObj quo = SCM_OBJ_INIT, rem = SCM_OBJ_INIT;
ScmObj expected_quo = SCM_OBJ_INIT, expected_rem = SCM_OBJ_INIT;
SCM_REFSTK_INIT_REG(&bn1, &bn2, &quo, &rem,
&expected_quo, &expected_rem);
bn1 = ut_read_cstr("-23058430092136939520");
bn2 = ut_read_cstr("-9223372036854775808");
TEST_ASSERT_TRUE(scm_bignum_p(bn1));
TEST_ASSERT_TRUE(scm_bignum_p(bn2));
expected_quo = ut_read_cstr("2");
expected_rem = ut_read_cstr("-4611686018427387904");
TEST_ASSERT_EQUAL_INT(0, scm_capi_truncate_div(bn1, bn2,
SCM_CSETTER_L(quo),
SCM_CSETTER_L(rem)));
TEST_ASSERT_SCM_TRUE(scm_num_eq_P(expected_quo, quo));
TEST_ASSERT_SCM_TRUE(scm_num_eq_P(expected_rem, rem));
}
示例10: test_nanocoap__server_get_req
/* Server GET request success case. */
static void test_nanocoap__server_get_req(void)
{
uint8_t buf[_BUF_SIZE];
coap_pkt_t pkt;
char path[] = "/riot/value";
int res = _read_riot_value_req(&pkt, &buf[0]);
TEST_ASSERT_EQUAL_INT(0, res);
TEST_ASSERT_EQUAL_INT(COAP_METHOD_GET, coap_get_code(&pkt));
TEST_ASSERT_EQUAL_INT(2, coap_get_token_len(&pkt));
TEST_ASSERT_EQUAL_INT(4 + 2, coap_get_total_hdr_len(&pkt));
TEST_ASSERT_EQUAL_INT(COAP_TYPE_NON, coap_get_type(&pkt));
TEST_ASSERT_EQUAL_INT(0, pkt.payload_len);
char uri[64] = {0};
coap_get_uri_path(&pkt, (uint8_t *)&uri[0]);
TEST_ASSERT_EQUAL_STRING((char *)path, (char *)uri);
}
示例11: test_routing_id
void test_routing_id ()
{
// Create the infrastructure
void *sc = test_context_socket (ZMQ_DEALER);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, "inproc://routing_id"));
void *sb = test_context_socket (ZMQ_ROUTER);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, "inproc://routing_id"));
// Send 2-part message.
TEST_ASSERT_EQUAL_INT (
1, TEST_ASSERT_SUCCESS_ERRNO (zmq_send (sc, "A", 1, ZMQ_SNDMORE)));
TEST_ASSERT_EQUAL_INT (
1, TEST_ASSERT_SUCCESS_ERRNO (zmq_send (sc, "B", 1, 0)));
// Routing id comes first.
zmq_msg_t msg;
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init (&msg));
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, sb, 0));
TEST_ASSERT_EQUAL_INT (1, zmq_msg_more (&msg));
// Then the first part of the message body.
TEST_ASSERT_EQUAL_INT (
1, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, sb, 0)));
TEST_ASSERT_EQUAL_INT (1, zmq_msg_more (&msg));
// And finally, the second part of the message body.
TEST_ASSERT_EQUAL_INT (
1, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, sb, 0)));
TEST_ASSERT_EQUAL_INT (0, zmq_msg_more (&msg));
// Deallocate the infrastructure.
test_context_socket_close (sc);
test_context_socket_close (sb);
}
示例12: test_data_can_create_complex_tree
void test_data_can_create_complex_tree(void)
{
TEST_IGNORE();
int tree_data[] = { 4, 2, 6, 1, 3, 5, 7 };
node_t *tree = build_tree(tree_data, ARRAY_SIZE(tree_data));
TEST_ASSERT_NOT_NULL(tree);
TEST_ASSERT_EQUAL_INT(4, tree->data);
TEST_ASSERT_NOT_NULL(tree->left);
TEST_ASSERT_NOT_NULL(tree->right);
TEST_ASSERT_EQUAL_INT(2, tree->left->data);
TEST_ASSERT_NOT_NULL(tree->left->left);
TEST_ASSERT_NOT_NULL(tree->left->right);
TEST_ASSERT_EQUAL_INT(6, tree->right->data);
TEST_ASSERT_NOT_NULL(tree->right->left);
TEST_ASSERT_NOT_NULL(tree->right->right);
TEST_ASSERT_EQUAL_INT(1, tree->left->left->data);
TEST_ASSERT_NULL(tree->left->left->left);
TEST_ASSERT_NULL(tree->left->left->right);
TEST_ASSERT_EQUAL_INT(3, tree->left->right->data);
TEST_ASSERT_NULL(tree->left->right->left);
TEST_ASSERT_NULL(tree->left->right->right);
TEST_ASSERT_EQUAL_INT(5, tree->right->left->data);
TEST_ASSERT_NULL(tree->right->left->left);
TEST_ASSERT_NULL(tree->right->left->right);
TEST_ASSERT_EQUAL_INT(7, tree->right->right->data);
TEST_ASSERT_NULL(tree->right->right->left);
TEST_ASSERT_NULL(tree->right->right->right);
free_tree(tree);
}
示例13: test_pktbuf_add__in_place
static void test_pktbuf_add__in_place(void)
{
ng_pktsnip_t *pkt = ng_pktbuf_add(NULL, TEST_STRING16, sizeof(TEST_STRING16),
NG_NETTYPE_UNDEF);
ng_pktsnip_t *header;
TEST_ASSERT_NOT_NULL((header = ng_pktbuf_add(pkt, pkt->data, 4, NG_NETTYPE_UNDEF)));
TEST_ASSERT(header == pkt->next);
TEST_ASSERT_EQUAL_STRING(TEST_STRING16, header->data); /* there is no 0 byte */
TEST_ASSERT_EQUAL_INT(4, header->size);
TEST_ASSERT_EQUAL_INT(NG_NETTYPE_UNDEF, header->type);
TEST_ASSERT_EQUAL_INT(1, header->users);
TEST_ASSERT_EQUAL_STRING(TEST_STRING16 + 4, pkt->data);
TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING16) - 4, pkt->size);
TEST_ASSERT_EQUAL_INT(NG_NETTYPE_UNDEF, pkt->type);
TEST_ASSERT_EQUAL_INT(1, pkt->users);
ng_pktbuf_release(header);
ng_pktbuf_release(pkt);
TEST_ASSERT(ng_pktbuf_is_empty());
}
示例14: test_gcoap__client_get_req
/*
* Client GET request success case. Test request generation.
* Request /time resource from libcoap example
* Includes 2-byte token
*/
static void test_gcoap__client_get_req(void)
{
uint8_t buf[GCOAP_PDU_BUF_SIZE];
coap_pkt_t pdu;
size_t len;
char path[] = "/time";
uint8_t pdu_data[] = {
0x52, 0x01, 0xe6, 0x02, 0x9b, 0xce, 0xb4, 0x74,
0x69, 0x6d, 0x65
};
len = gcoap_request(&pdu, &buf[0], GCOAP_PDU_BUF_SIZE, COAP_METHOD_GET,
&path[0]);
TEST_ASSERT_EQUAL_INT(COAP_METHOD_GET, coap_get_code(&pdu));
TEST_ASSERT_EQUAL_INT(GCOAP_TOKENLEN, coap_get_token_len(&pdu));
TEST_ASSERT_EQUAL_INT(4 + GCOAP_TOKENLEN, coap_get_total_hdr_len(&pdu));
TEST_ASSERT_EQUAL_INT(COAP_TYPE_NON, coap_get_type(&pdu));
TEST_ASSERT_EQUAL_STRING(&path[0], (char *)&pdu.url[0]);
TEST_ASSERT_EQUAL_INT(0, pdu.payload_len);
TEST_ASSERT_EQUAL_INT(sizeof(pdu_data), len);
}
示例15: test_pkt_len__1_elem__size_data
static void test_pkt_len__1_elem__size_data(void)
{
gnrc_pktsnip_t snip = _INIT_ELEM_STATIC_DATA(TEST_STRING8, NULL);
TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING8), gnrc_pkt_len(&snip));
}