本文整理汇总了C++中TC_SUCCESS_RESULT函数的典型用法代码示例。如果您正苦于以下问题:C++ TC_SUCCESS_RESULT函数的具体用法?C++ TC_SUCCESS_RESULT怎么用?C++ TC_SUCCESS_RESULT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TC_SUCCESS_RESULT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tc_libcxx_strings_string_assign_size_char
int tc_libcxx_strings_string_assign_size_char(void)
{
{
typedef std::string S;
TC_ASSERT_FUNC((test(S(), 0, 'a', S())));
TC_ASSERT_FUNC((test(S(), 1, 'a', S(1, 'a'))));
TC_ASSERT_FUNC((test(S(), 10, 'a', S(10, 'a'))));
TC_ASSERT_FUNC((test(S(), 100, 'a', S(100, 'a'))));
TC_ASSERT_FUNC((test(S("12345"), 0, 'a', S())));
TC_ASSERT_FUNC((test(S("12345"), 1, 'a', S(1, 'a'))));
TC_ASSERT_FUNC((test(S("12345"), 10, 'a', S(10, 'a'))));
TC_ASSERT_FUNC((test(S("12345678901234567890"), 0, 'a', S())));
TC_ASSERT_FUNC((test(S("12345678901234567890"), 1, 'a', S(1, 'a'))));
TC_ASSERT_FUNC((test(S("12345678901234567890"), 10, 'a', S(10, 'a'))));
}
TC_SUCCESS_RESULT();
return 0;
}
示例2: tc_libcxx_containers_unord_map_types
int tc_libcxx_containers_unord_map_types(void)
{
{
typedef std::unordered_map<char, short> C;
static_assert((std::is_same<C::key_type, char>::value), "");
static_assert((std::is_same<C::mapped_type, short>::value), "");
static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
static_assert((std::is_same<C::reference, C::value_type&>::value), "");
static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
static_assert((std::is_same<C::size_type, std::size_t>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
TC_SUCCESS_RESULT();
return 0;
}
示例3: tc_libc_misc_crc16part
/**
* @fn :tc_libc_misc_crc16part
* @brief :Continue CRC calculation on a part of the buffer.
* @scenario :Continue CRC calculation on a part of the buffer.
* @API's covered :crc16part
* @Preconditions :None
* @Postconditions :None
* @Return :void
*/
static void tc_libc_misc_crc16part(void)
{
uint16_t ret_chk;
uint8_t src_arr[1] = { VAL_100 };
uint16_t crc_16val = 0;
size_t length = 1;
/* Return value should be 100 as calculated by crc16part */
ret_chk = crc16part(src_arr, length, crc_16val);
TC_ASSERT_EQ("crc16part", ret_chk, VAL_100);
/* Return value should be 65380 as calculated by crc16part */
crc_16val = VAL_255;
ret_chk = crc16part(src_arr, length, crc_16val);
TC_ASSERT_EQ("crc16part", ret_chk, VAL_65380);
TC_SUCCESS_RESULT();
}
示例4: tc_libcxx_strings_string_erase_iter
int tc_libcxx_strings_string_erase_iter(void)
{
{
typedef std::string S;
TC_ASSERT_FUNC((test(S("abcde"), 0, S("bcde"))));
TC_ASSERT_FUNC((test(S("abcde"), 1, S("acde"))));
TC_ASSERT_FUNC((test(S("abcde"), 2, S("abde"))));
TC_ASSERT_FUNC((test(S("abcde"), 4, S("abcd"))));
TC_ASSERT_FUNC((test(S("abcdefghij"), 0, S("bcdefghij"))));
TC_ASSERT_FUNC((test(S("abcdefghij"), 1, S("acdefghij"))));
TC_ASSERT_FUNC((test(S("abcdefghij"), 5, S("abcdeghij"))));
TC_ASSERT_FUNC((test(S("abcdefghij"), 9, S("abcdefghi"))));
TC_ASSERT_FUNC((test(S("abcdefghijklmnopqrst"), 0, S("bcdefghijklmnopqrst"))));
TC_ASSERT_FUNC((test(S("abcdefghijklmnopqrst"), 1, S("acdefghijklmnopqrst"))));
TC_ASSERT_FUNC((test(S("abcdefghijklmnopqrst"), 10, S("abcdefghijlmnopqrst"))));
TC_ASSERT_FUNC((test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"))));
}
TC_SUCCESS_RESULT();
return 0;
}
示例5: tc_libcxx_strings_string_cons_pointer_alloc
int tc_libcxx_strings_string_cons_pointer_alloc(void)
{
{
typedef test_allocator<char> A;
TC_ASSERT_FUNC((test("")));
TC_ASSERT_FUNC((test("", A(2))));
TC_ASSERT_FUNC((test("1")));
TC_ASSERT_FUNC((test("1", A(2))));
TC_ASSERT_FUNC((test("1234567980")));
TC_ASSERT_FUNC((test("1234567980", A(2))));
TC_ASSERT_FUNC((test("123456798012345679801234567980123456798012345679801234567980")));
TC_ASSERT_FUNC((test("123456798012345679801234567980123456798012345679801234567980", A(2))));
}
TC_SUCCESS_RESULT();
return 0;
}
示例6: itc_mqtt_connect_disconnect_p
void itc_mqtt_connect_disconnect_p(void)
{
int res;
g_mqtt_client_handle = mqtt_init_client(&g_mqtt_client_config);
TC_ASSERT_NEQ("mqtt_init_client", g_mqtt_client_handle, NULL);
// MQTT Connect
res = mqtt_connect(g_mqtt_client_handle, CONFIG_ITC_MQTT_BROKER_ADDR, CONFIG_ITC_MQTT_BROKER_PORT, 0);
TC_ASSERT_EQ("mqtt_connect", res, 0);
ITC_MQTT_WAIT_SIGNAL;
//MQTT Disconnect
res = mqtt_disconnect(g_mqtt_client_handle);
TC_ASSERT_EQ("mqtt_disconnect", res, 0);
ITC_MQTT_WAIT_SIGNAL;
res = mqtt_deinit_client(g_mqtt_client_handle);
TC_ASSERT_EQ("mqtt_deinit_client", res, 0);
TC_SUCCESS_RESULT();
}
示例7: tc_pthread_pthread_kill
/**
* @fn :tc_pthread_pthread_kill
* @brief :send a signal to a thread
* @Scenario :The pthread_kill() function sends the signal sig to thread, a thread
* in the same process as the caller. The signal is asynchronously
* directed to thread.
* API's covered :pthread_kill, pthread_join
* Preconditions :none
* Postconditions :none
* @return :void
*/
static void tc_pthread_pthread_kill(void)
{
int ret_chk;
g_bpthreadcallback = false;
ret_chk = pthread_create(&g_thread1, NULL, thread_kill_func_callback, NULL);
if (ret_chk != OK) {
tckndbg("ERROR pthread_create FAIL\n");
pthread_detach(g_thread1);
}
sleep(SEC_2);
ret_chk = pthread_kill(g_thread1, SIGUSR1);
sleep(SEC_1);
TC_ASSERT_EQ_CLEANUP("pthread_kill", ret_chk, OK, pthread_detach(g_thread1));
TC_ASSERT_EQ_CLEANUP("pthread_kill", g_bpthreadcallback, true, pthread_detach(g_thread1));
pthread_join(g_thread1, NULL);
TC_SUCCESS_RESULT();
}
示例8: itc_net_listen_p_different_socket
/**
* @testcase :itc_net_listen_p_different_socket
* @brief :listen for socket connections and limit the queue of incoming connections
* @scenario :create socket, bind it and then listen
* @apicovered :listen()
* @precondition :open socket
* @postcondition :close socket
*/
static void itc_net_listen_p_different_socket(void)
{
struct sockaddr_in sa;
struct sockaddr_in saddr;
int socket_fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
TC_ASSERT_GEQ("socket", socket_fd, CONFIG_NFILE_DESCRIPTORS);
int fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
TC_ASSERT_GEQ("socket", fd, CONFIG_NFILE_DESCRIPTORS);
memset(&sa, 0, sizeof sa);
memset(&saddr, 0, sizeof saddr);
sa.sin_family = AF_INET;
sa.sin_port = htons(ADDR_PORT);
sa.sin_addr.s_addr = htonl(INADDR_ANY);
saddr.sin_family = AF_INET;
saddr.sin_port = htons(SOCK_PORT);
saddr.sin_addr.s_addr = htonl(INADDR_ANY);
int ret = bind(socket_fd, (struct sockaddr *)&sa, sizeof(sa));
TC_ASSERT_EQ_CLEANUP("bind", ret, 0, close(socket_fd); close(fd));
ret = bind(fd, (struct sockaddr *)&saddr, sizeof(saddr));
TC_ASSERT_EQ_CLEANUP("bind", ret, 0, close(socket_fd); close(fd));
ret = listen(socket_fd, BACK_LOG);
TC_ASSERT_EQ_CLEANUP("listen", ret, 0, close(socket_fd); close(fd));
ret = listen(fd, BACK_LOG);
TC_ASSERT_EQ_CLEANUP("listen", ret, 0, close(socket_fd); close(fd));
ret = close(socket_fd);
TC_ASSERT_EQ_CLEANUP("close", ret, 0, close(fd));
ret = close(fd);
TC_ASSERT_EQ("close", ret, 0);
TC_SUCCESS_RESULT();
}
示例9: tc_libc_spawn_add_file_action
/**
* @fn : tc_libc_spawn_add_file_action
* @brief : Add the file action
* @scenario : Add the file action to the end for the file action list
* @API's covered : posix_spawn_file_actions_init, posix_spawn_file_actions_addopen, add_file_action
* @Preconditions : posix_spawn_file_actions_init,posix_spawn_file_actions_addopen
* @Postconditions : posix_spawn_file_actions_destroy
* @Return : void
*/
static void tc_libc_spawn_add_file_action(void)
{
const char szfilepath[] = "./testdata.txt";
posix_spawn_file_actions_t st_fileactions;
struct spawn_open_file_action_s *entry1;
struct spawn_open_file_action_s *entry2;
size_t length;
size_t alloc_num;
int ret_chk = ERROR;
ret_chk = posix_spawn_file_actions_init(&st_fileactions);
TC_ASSERT_EQ("posix_spawn_file_actions_init", ret_chk, OK);
ret_chk = posix_spawn_file_actions_addopen(&st_fileactions, 1, szfilepath, O_WRONLY, 0644);
TC_ASSERT_EQ("posix_spawn_file_actions_addopen", ret_chk, OK);
length = strlen(szfilepath);
alloc_num = SIZEOF_OPEN_FILE_ACTION_S(length);
/* Allocate the action list entry of this size */
entry1 = (struct spawn_open_file_action_s *)zalloc(alloc_num);
TC_ASSERT_NOT_NULL("zalloc", entry1);
/* And add it to the file action list */
add_file_action(st_fileactions, (struct spawn_general_file_action_s *)entry1);
entry2 = (struct spawn_open_file_action_s *)zalloc(alloc_num);
TC_ASSERT_NOT_NULL("zalloc", entry2);
/* And add it to the file action list */
add_file_action(st_fileactions, (struct spawn_general_file_action_s *)entry2);
TC_ASSERT_EQ("add_file_action", entry1->flink, (struct spawn_general_file_action_s *)entry2);
ret_chk = posix_spawn_file_actions_destroy(&st_fileactions);
TC_ASSERT_EQ("posix_spawn_file_actions_destroy", ret_chk, OK);
TC_SUCCESS_RESULT();
}
示例10: tc_pthread_pthread_create_exit_join
/**
* @fn :tc_pthread_pthread_create_exit_join
* @brief :creates a new thread with a specified attributes and \
* terminates execution of a thread started with pthread_create.
* @Scenario :creates a new thread with a specified attributes and \
* terminates execution of a thread started with pthread_create.
* API's covered :pthread_create, pthread_exit, pthread_join
* Preconditions :none
* Postconditions :none
* @return :void
*/
static void tc_pthread_pthread_create_exit_join(void)
{
int ret_chk;
pthread_t pthread;
void *p_value = 0;
isemaphore = ERROR;
ret_chk = pthread_create(&pthread, NULL, task_exit, NULL);
TC_ASSERT_EQ("pthread create", ret_chk, OK);
/* To make sure thread is created before we join it */
while (isemaphore == INTHREAD) {
sleep(SEC_1);
}
ret_chk = pthread_join(pthread, &p_value);
TC_ASSERT_EQ("pthread_join", ret_chk, OK);
TC_ASSERT_EQ("pthread_join", p_value, RETURN_PTHREAD_JOIN);
TC_SUCCESS_RESULT();
}
示例11: tc_pthread_pthread_equal
static void tc_pthread_pthread_equal(void)
{
int ret_chk;
pthread_t first_th;
pthread_t second_th;
bool check_same;
ret_chk = pthread_create(&first_th, NULL, do_nothing_thread, NULL);
TC_ASSERT_EQ("pthread_create", ret_chk, OK);
ret_chk = pthread_create(&second_th, NULL, do_nothing_thread, NULL);
TC_ASSERT_EQ("pthread_create", ret_chk, OK);
pthread_join(first_th, NULL);
pthread_join(second_th, NULL);
check_same = pthread_equal(first_th, second_th);
TC_ASSERT_EQ("pthread_equal", check_same, false);
TC_SUCCESS_RESULT();
}
示例12: itc_net_inet_ntop_n
/**
* @testcase :itc_net_inet_ntop_n
* @brief :function converts the network address structure src
* in the af address family into a character string*
* @scenario :passing invalid args to inet_ntop
* @apicovered :inet_ntop()
* @precondition :None
* @postcondition :None
*/
static void itc_net_inet_ntop_n(void)
{
struct in_addr in_addr;
char dst[INET_ADDRSTRLEN];
const char *ret;
in_addr.s_addr = 0x17071994;
#ifdef CONFIG_NET_IPv4
ret = inet_ntop(AF_INET, &in_addr, dst, 7);
TC_ASSERT_EQ("inet_ntop", ret, NULL);
#endif
#ifdef CONFIG_NET_IPv6
ret = inet_ntop(AF_INET6, &in_addr, dst, 7);
TC_ASSERT_EQ("inet_ntop", ret, NULL);
#endif
ret = inet_ntop(33, &in_addr, dst, INET_ADDRSTRLEN);
TC_ASSERT_EQ("inet_ntop", ret, NULL);
TC_SUCCESS_RESULT();
}
示例13: tc_pthread_pthread_cancel_setcancelstate
/**
* @fn :tc_pthread_pthread_cancel_setcancelstate
* @brief :set cancelability state and type and sends a cancellation request to a thread
* @Scenario :The pthread_setcancelstate() sets the cancelability state of the calling
* thread to the value given in state. The pthread_cancel() function sends a cancellation request to the thread thread.
* Whether and when the target thread reacts to the cancellation request depends
* on two attributes that are under the control of that thread:
* its cancelability state and type
* API's covered :pthread_setcancelstate, pthread_cancel
* Preconditions :none
* Postconditions :none
* @return :void
*/
static void tc_pthread_pthread_cancel_setcancelstate(void)
{
int ret_chk;
g_bpthreadcallback = false;
ret_chk = pthread_create(&g_thread1, NULL, cancel_state_func, NULL);
TC_ASSERT_EQ_CLEANUP("pthread_create", ret_chk, OK, pthread_detach(g_thread1));
sleep(SEC_1);
/* this cancel request goes to pending if cancel is disabled */
ret_chk = pthread_cancel(g_thread1);
TC_ASSERT_EQ_CLEANUP("pthread_cancel", ret_chk, OK, pthread_detach(g_thread1));
sleep(SEC_3);
TC_ASSERT("pthread_cancel", g_bpthreadcallback);
ret_chk = pthread_detach(g_thread1);
TC_ASSERT_EQ("pthread_detach", ret_chk, OK);
TC_SUCCESS_RESULT();
}
示例14: itc_systemio_iotbus_uart_set_mode_p
/**
* @testcase itc_systemio_iotbus_uart_set_mode_p
* @brief sets byte size, parity bit and stop bits
* @scenario sets byte size, parity bit and stop bits
* @apicovered iotbus_uart_set_mode
* @precondition initializes uart_context
* @postcondition closes uart_context
*/
void itc_systemio_iotbus_uart_set_mode_p(void)
{
int i_bytesize = 8;
int i_stop_bits = 1;
int ret = IOTBUS_ERROR_NONE;
int mode[] = { IOTBUS_UART_PARITY_NONE, IOTBUS_UART_PARITY_EVEN, IOTBUS_UART_PARITY_ODD };
int i_modes = sizeof(mode) / sizeof(int);
int index = 0;
iotbus_uart_context_h h_uart = iotbus_uart_init(DEVPATH);
TC_ASSERT_NEQ("iotbus_uart_init", h_uart, NULL);
for (index = 0; index < i_modes; index++) {
ret = iotbus_uart_set_mode(h_uart, i_bytesize, mode[index], i_stop_bits);
TC_ASSERT_EQ_CLEANUP("iotbus_uart_set_mode", ret, IOTBUS_ERROR_NONE, iotbus_uart_stop(h_uart));
}
ret = iotbus_uart_stop(h_uart);
TC_ASSERT_EQ("iotbus_uart_stop", ret, IOTBUS_ERROR_NONE);
TC_SUCCESS_RESULT();
}
示例15: tc_libcxx_thread_thread_lock_unique_cons_mutex_adopt_lock
int tc_libcxx_thread_thread_lock_unique_cons_mutex_adopt_lock(void)
{
{
typedef std::mutex M;
M m;
m.lock();
std::unique_lock<M> lk(m, std::adopt_lock);
TC_ASSERT_EXPR(lk.mutex() == std::addressof(m));
TC_ASSERT_EXPR(lk.owns_lock() == true);
}
{
typedef nasty_mutex M;
M m;
m.lock();
std::unique_lock<M> lk(m, std::adopt_lock);
TC_ASSERT_EXPR(lk.mutex() == std::addressof(m));
TC_ASSERT_EXPR(lk.owns_lock() == true);
}
TC_SUCCESS_RESULT();
return 0;
}