您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ BTASSERT函数代码示例

51自学网 2021-06-01 19:53:33
  C++
这篇教程C++ BTASSERT函数代码示例写得很实用,希望能帮到您。

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

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

示例1: test_get_by_name

int test_get_by_name(struct harness_t *harness_p){    BTASSERT(thrd_get_by_name("main") == thrd_self());    BTASSERT(thrd_get_by_name("none") == NULL);    return (0);}
开发者ID:wuwx,项目名称:simba,代码行数:7,


示例2: test_init

static int test_init(struct harness_t *harness_p){    struct thrd_t *thrd_p;    int port = REMOTE_HOST_PORT;    char remote_host_ip[] = STRINGIFY(REMOTE_HOST_IP);    struct inet_addr_t remote_host_address;    self_p = thrd_self();    std_printf(FSTR("Connecting to '%s:%d'./r/n"), remote_host_ip, port);    BTASSERT(inet_aton(remote_host_ip, &remote_host_address.ip) == 0);    remote_host_address.port = port;    BTASSERT(socket_open_tcp(&server_sock) == 0);    BTASSERT(socket_connect(&server_sock, &remote_host_address) == 0);    BTASSERT(mqtt_client_init(&client,                              "mqtt_client",                              NULL,                              &server_sock,                              &server_sock,                              on_publish,                              NULL) == 0);    thrd_p = thrd_spawn(mqtt_client_main,                        &client,                        0,                        stack,                        sizeof(stack));    thrd_set_log_mask(thrd_p, LOG_UPTO(DEBUG));    return (0);}
开发者ID:wuwx,项目名称:simba,代码行数:35,


示例3: test_stack_heap

int test_stack_heap(struct harness_t *harness_p){    BTASSERT(thrd_stack_alloc(1) == NULL);    BTASSERT(thrd_stack_free(NULL) == -1);    return (0);}
开发者ID:wuwx,项目名称:simba,代码行数:7,


示例4: test_disconnect

static int test_disconnect(struct harness_t *harness_p){    BTASSERT(mqtt_client_disconnect(&client) == 0);    BTASSERT(socket_close(&server_sock) == 0);    return (0);}
开发者ID:wuwx,项目名称:simba,代码行数:7,


示例5: test_get_temp

int test_get_temp(struct harness_t *harness_p){    struct owi_driver_t owi;    struct ds18b20_driver_t ds;    struct owi_device_t devices[4];    char buf[24];    int number_of_sensors;    BTASSERT(owi_init(&owi, &pin_d7_dev, devices, membersof(devices)) == 0);    BTASSERT(ds18b20_init(&ds, &owi) == 0);    time_busy_wait_us(50000);    number_of_sensors = owi_search(&owi);    std_printf(FSTR("number_of_sensors = %d/r/n"), number_of_sensors);    BTASSERT(number_of_sensors == 2);    strcpy(buf, "drivers/ds18b20/list");    BTASSERT(fs_call(buf, NULL, sys_get_stdout(), NULL) == 0);    time_busy_wait_us(50000);    return (0);}
开发者ID:eerimoq,项目名称:simba,代码行数:26,


示例6: test_alloc_free

static int test_alloc_free(struct harness_t *harness){    int i;    struct heap_t heap;    void *buffers[16];    size_t sizes[8] = { 16, 32, 64, 128, 256, 512, 512, 512 };    BTASSERT(heap_init(&heap, buffer, sizeof(buffer), sizes) == 0);    /* Allocate a few buffers... */    for (i = 0; i < 16; i++) {        buffers[i] = heap_alloc(&heap, 1 + (4 * i));        BTASSERT(buffers[i] != NULL);    }    /* ...and free them. */    for (i = 0; i < 16; i++) {        BTASSERT(heap_free(&heap, buffers[i]) == 0);    }    /* Allocate from the free list... */    for (i = 0; i < 16; i++) {        buffers[i] = heap_alloc(&heap, 1 + (4 * i));        BTASSERT(buffers[i] != NULL);    }    /* ...and free them. */    for (i = 0; i < 16; i++) {        BTASSERT(heap_free(&heap, buffers[i]) == 0);    }    return (0);}
开发者ID:eerimoq,项目名称:simba,代码行数:33,


示例7: test_duty_cycle_convert

static int test_duty_cycle_convert(struct harness_t *harness_p){    BTASSERT(pwm_soft_duty_cycle_as_percent(pwm_soft_duty_cycle(0)) == 0);    BTASSERT(pwm_soft_duty_cycle_as_percent(pwm_soft_duty_cycle(100)) == 100);    return (0);}
开发者ID:eerimoq,项目名称:simba,代码行数:7,


示例8: test_pcm1611s

static int test_pcm1611s(struct harness_t *harness_p){#if !defined(SKIP_TEST_PCM1611S)    int i;    int samples_per_second = 2 * 11025;    struct dac_driver_t dac;    BTASSERT(dac_init(&dac,                      &dac_0_dev,                      &pin_0_dev,                      &pin_1_dev,                      samples_per_second) == 0);    for (i = 0; i < membersof(dac_gen_pcm1611s); i += 4096) {        memcpy(samples, &dac_gen_pcm1611s[i], sizeof(samples));        BTASSERT(dac_async_convert(&dac,                                   (uint32_t *)samples,                                   4096 / 2) == 0);    }    BTASSERT(dac_async_wait(&dac) == 0);    return (0);#else        return (1);    #endif}
开发者ID:wuwx,项目名称:simba,代码行数:31,


示例9: test_init

static int test_init(struct harness_t *harness_p){    BTASSERT(random_module_init() == 0);    BTASSERT(random_module_init() == 0);    return (0);}
开发者ID:wuwx,项目名称:simba,代码行数:7,


示例10: test_exti

int test_exti(struct harness_t *harness_p){    int i;    struct exti_driver_t exti;    struct pin_driver_t pin;    pin_init(&pin, &pin_d4_dev, PIN_OUTPUT);    pin_write(&pin, 1);        BTASSERT(exti_init(&exti,                       &exti_d3_dev,                       EXTI_TRIGGER_FALLING_EDGE,                       isr,                       NULL) == 0);    BTASSERT(exti_start(&exti) == 0);    for (i = 0; i < 10; i++) {        pin_write(&pin, 0);        time_busy_wait_us(10000);        pin_write(&pin, 1);        time_busy_wait_us(10000);    }    std_printf(FSTR("flag = %d/r/n"), (int)flag);    BTASSERT(flag == 10);    return (0);}
开发者ID:wuwx,项目名称:simba,代码行数:28,


示例11: test_get_comments

static int test_get_comments(struct harness_t *harness_p){    struct configfile_t configfile;    char buf[] =        "[shopping list]/n"        "#milk = 3/n/r"        "cheese = 1 cheddar/r/n"        ";ham = 1";    char value[16];    BTASSERT(configfile_init(&configfile, buf, sizeof(buf)) == 0);    /* Get the value of property 'milk' in section 'shopping       list'. Finds nothing since the milk line is a coment.*/    BTASSERT(configfile_get(&configfile,                            "shopping list",                             "milk",                             value,                            sizeof(value)) == NULL);    /* Get the value of property 'cheese' in section 'shopping       list'. */    BTASSERT(configfile_get(&configfile,                            "shopping list",                            "cheese",                            &value[0],                            sizeof(value)) == &value[0]);    BTASSERT(strcmp(&value[0], "1 cheddar") == 0);    return (0);}
开发者ID:wuwx,项目名称:simba,代码行数:31,


示例12: test_write

static int test_write(struct harness_t *harness_p){    BTASSERT(analog_output_pin_write(&pin, 256) == 0);    BTASSERT(analog_output_pin_read(&pin) == 256);        return (0);}
开发者ID:eerimoq,项目名称:simba,代码行数:7,


示例13: test_init

int test_init(struct harness_t *harness_p){#if defined(ARCH_LINUX)    /* Create an empty sd card file. */    system("../../create_sdcard_linux.sh");    file_p = fopen("sdcard", "r+b");    BTASSERT(fat16_init(&fs,                        linux_read_block,                        linux_write_block,                        file_p,                        0) == 0);#else    BTASSERT(spi_init(&spi,                      &spi_device[0],                      &pin_d6_dev,                      SPI_MODE_MASTER,                      SPI_SPEED_500KBPS,                      0,                      0) == 0);    BTASSERT(sd_init(&sd, &spi) == 0);    BTASSERT(sd_start(&sd) == 0);    BTASSERT(fat16_init(&fs,                        (fat16_read_t)sd_read_block,                        (fat16_write_t)sd_write_block,                        &sd,                        0) == 0);#endif    return (0);}
开发者ID:eerimoq,项目名称:simba,代码行数:30,


示例14: test_read_write_bad_address

static int test_read_write_bad_address(struct harness_t *harness_p){    uint8_t buf[2];    memset(&buf[0], 0, sizeof(buf));    /* Start address outside the EEPROM. */    BTASSERT(eeprom_i2c_read(&eeprom_i2c,                             &buf[0],                             EEPROM_SIZE,                             sizeof(buf)) == -EINVAL);    BTASSERT(eeprom_i2c_write(&eeprom_i2c,                              EEPROM_SIZE,                              &buf[0],                              sizeof(buf)) == -EINVAL);    /* End address outside the EEPROM. */    BTASSERT(eeprom_i2c_read(&eeprom_i2c,                             &buf[0],                             EEPROM_SIZE - 1,                             sizeof(buf)) == -EINVAL);    BTASSERT(eeprom_i2c_write(&eeprom_i2c,                              EEPROM_SIZE - 1,                              &buf[0],                              sizeof(buf)) == -EINVAL);    return (0);}
开发者ID:wuwx,项目名称:simba,代码行数:30,


示例15: test_get_whitespace

static int test_get_whitespace(struct harness_t *harness_p){    struct configfile_t configfile;    char buf[] =        "[shopping list]  /n"        "milk  :   3   /t /r/n"        "cheese/t:  1 cheddar  /r/n";    char value[16];    BTASSERT(configfile_init(&configfile, buf, sizeof(buf)) == 0);    /* Get the value of property 'milk' in section 'shopping list'. */    BTASSERT(configfile_get(&configfile,                            "shopping list",                             "milk",                             value,                            sizeof(value)) == &value[0]);    BTASSERT(strcmp(&value[0], "3") == 0);    /* Get the value of property 'cheese' in section 'shopping       list'. */    BTASSERT(configfile_get(&configfile,                            "shopping list",                            "cheese",                            &value[0],                            sizeof(value)) == &value[0]);    BTASSERT(strcmp(&value[0], "1 cheddar") == 0);    return (0);}
开发者ID:wuwx,项目名称:simba,代码行数:30,


示例16: test_bad_file

static int test_bad_file(struct harness_t *harness_p){    struct fat16_file_t foo;    /* Directory APA does not exist. */    BTASSERT(fat16_file_open(&fs,                             &foo,                             "APA/BAR.TXT",                             O_CREAT | O_WRITE | O_SYNC) == -1);    /* Trying to open a directory as a file. */    BTASSERT(fat16_file_open(&fs,                             &foo,                             "HOME",                             O_CREAT | O_WRITE | O_SYNC) == -1);    /* Invalid 8.3 file name. */    BTASSERT(fat16_file_open(&fs,                             &foo,                             "toolongfilename.txt",                             O_CREAT | O_WRITE | O_SYNC) == -1);    /* Invalid 8.3 file name. */    BTASSERT(fat16_file_open(&fs,                             &foo,                             "|",                             O_CREAT | O_WRITE | O_SYNC) == -1);    return (0);}
开发者ID:eerimoq,项目名称:simba,代码行数:30,


示例17: test_server

static int test_server(struct harness_t *harness_p){    struct ssl_context_t context;    struct ssl_socket_t ssl_socket;    struct socket_t listener, socket;    struct inet_addr_t addr;    char buf[8];    /* Create a context with default settings. */    BTASSERT(ssl_context_init(&context) == 0);    /* Create a socket and connect to the server. */    BTASSERT(socket_open_tcp(&listener) == 0);    BTASSERT(socket_listen(&listener, 5) == 0);    BTASSERT(socket_accept(&listener, &socket, &addr) == 0);    /* Wrap the socket in SSL. */    BTASSERT(ssl_socket_init(&ssl_socket,                             &context,                             &socket,                             ssl_socket_mode_server_t) == 0);    BTASSERT(ssl_socket_handshake(&ssl_socket) == 0);    /* Transfer data to and from the server. */    BTASSERT(ssl_socket_read(&ssl_socket, &buf[0], 6) == 6);    BTASSERT(strcmp("hello", buf) == 0);    BTASSERT(ssl_socket_write(&ssl_socket, "goodbye", 8) == 8);    /* Close the connection. */    BTASSERT(socket_close(&socket) == 0);    return (0);}
开发者ID:eerimoq,项目名称:simba,代码行数:33,


示例18: test_sleep

int test_sleep(struct harness_t *harness_p){    BTASSERT(thrd_sleep(0.001) == 0);    BTASSERT(thrd_sleep_ms(1) == 0);    BTASSERT(thrd_sleep_us(1000) == 0);    return (0);}
开发者ID:wuwx,项目名称:simba,代码行数:8,


示例19: test_priority

int test_priority(struct harness_t *harness_p){    BTASSERT(thrd_get_prio() == 0);    BTASSERT(thrd_set_prio(thrd_self(), 1) == 0);    BTASSERT(thrd_get_prio() == 1);    return (0);}
开发者ID:wuwx,项目名称:simba,代码行数:8,


示例20: test_start

static int test_start(struct harness_t *harness_p){    BTASSERT(bcm43362_init(&bcm43362,                           &sdio_0_dev) == 0);    BTASSERT(bcm43362_start(&bcm43362) == 0);    return (0);}
开发者ID:eerimoq,项目名称:simba,代码行数:8,


示例21: test_init

int test_init(struct harness_t *harness_p){    /* This function may be called multiple times. */    BTASSERT(thrd_module_init() == 0);    BTASSERT(thrd_module_init() == 0);    return (0);}
开发者ID:wuwx,项目名称:simba,代码行数:8,


示例22: test_init

int test_init(struct harness_t *harness_p){    /* Call init two times. */    BTASSERT(log_module_init() == 0);    BTASSERT(log_module_init() == 0);    return (0);}
开发者ID:wuwx,项目名称:simba,代码行数:8,


示例23: test_init

static int test_init(struct harness_t *harness_p){    BTASSERT(analog_output_pin_init(&pin, &pin_d10_dev) == 0);    /* Bad pwm pin. */    BTASSERT(analog_output_pin_init(&pin, &pin_d5_dev) == -1);    return (0);}
开发者ID:eerimoq,项目名称:simba,代码行数:9,


示例24: socket_bind

int socket_bind(struct socket_t *self_p,                const struct inet_addr_t *local_addr_p){    char buf[16];    BTASSERT(strcmp(inet_ntoa(&local_addr_p->ip, &buf[0]), "127.0.0.1") == 0);    BTASSERT(local_addr_p->port == 69);    return (0);}
开发者ID:wuwx,项目名称:simba,代码行数:10,


示例25: test_unmount

static int test_unmount(struct harness_t *harness_p){    BTASSERT(fat16_unmount(&fs) == 0);#if !defined(ARCH_LINUX)    BTASSERT(sd_stop(&sd) == 0);#endif    return (0);}
开发者ID:eerimoq,项目名称:simba,代码行数:10,


示例26: test_list

static int test_list(struct harness_t *harness_p){    struct chan_list_t list;    void *workspace[1];    struct chan_t chan[2];    BTASSERT(chan_init(&chan[0],                       chan_read_null,                       chan_write_null,                       chan_size_null) == 0);    BTASSERT(chan_init(&chan[1],                       chan_read_null,                       chan_write_null,                       chan_size_null) == 0);    BTASSERT(chan_list_init(&list, &workspace[0], sizeof(workspace)) == 0);    BTASSERT(chan_list_add(&list, &chan[0]) == 0);    BTASSERT(chan[0].list_p != NULL);    BTASSERT(chan_list_add(&list, &chan[1]) == -ENOMEM);    BTASSERT(chan_list_remove(&list, &chan[1]) == -1);    BTASSERT(chan_list_remove(&list, &chan[0]) == 0);    BTASSERT(chan[0].list_p == NULL);    return (0);}
开发者ID:wuwx,项目名称:simba,代码行数:25,


示例27: test_client

static int test_client(struct harness_t *harness_p){    struct ssl_context_t context;    struct ssl_socket_t ssl_socket;    struct socket_t socket;    struct inet_addr_t addr;    char buf[8];    /* Create a context with default settings. */    BTASSERT(ssl_context_init(&context) == 0);    /* Create a socket and connect to the server. */    BTASSERT(socket_open_tcp(&socket) == 0);    inet_aton("1.2.3.4", &addr.ip);    addr.port = 1234;    BTASSERT(socket_connect(&socket, &addr) == 0);    /* Wrap the socket in SSL. */    BTASSERT(ssl_socket_init(&ssl_socket,                             &context,                             &socket,                             ssl_socket_mode_client_t) == 0);    BTASSERT(ssl_socket_handshake(&ssl_socket) == 0);    /* Transfer data to and from the server. */    BTASSERT(ssl_socket_write(&ssl_socket, "hello", 6) == 6);    BTASSERT(ssl_socket_read(&ssl_socket, &buf[0], 8) == 8);    BTASSERT(strcmp("goodbye", buf) == 0);    /* Close the connection. */    BTASSERT(socket_close(&socket) == 0);    return (0);}
开发者ID:eerimoq,项目名称:simba,代码行数:35,


示例28: test_sine_440_hz

static int test_sine_440_hz(struct harness_t *harness_p){#if !defined(SKIP_TEST_SINE_440_HZ)        int i;    float sample;    int samples_per_second = (membersof(dac_gen_sine) * 440);    struct dac_driver_t dac;    int total_number_of_samples;    BTASSERT(dac_init(&dac,                      &dac_0_dev,                      &pin_0_dev,                      NULL,                      samples_per_second) == 0);    /* Samples are in the range -1.0 to 1.0. Convert them to the range       0 to AMPLITUDE_MAX. */    for (i = 0; i < membersof(samples); i++) {        sample = dac_gen_sine[i % membersof(dac_gen_sine)];        samples[i] =  AMPLITUDE_MAX * ((sample + 1.0) / 2.0);    }    std_printf(FSTR("Converting %d samples./r/n"), (int)membersof(samples));    BTASSERT(dac_convert(&dac, (uint32_t *)samples, membersof(samples) / 2) == 0);    /* Converting the signal on the DAC0-pin for 5 seconds. */    total_number_of_samples = (5 * samples_per_second);    std_printf(FSTR("Converting %d samples./r/n"),               total_number_of_samples);    for (i = 0; i < total_number_of_samples; i += membersof(samples)) {        BTASSERT(dac_async_convert(&dac,                                   (uint32_t *)samples,                                   membersof(samples) / 2) == 0);        std_printf(FSTR("Samples left = %d/r/n"), total_number_of_samples - i);    }    std_printf(FSTR("Waiting for last samples to be converted/r/n"));    BTASSERT(dac_async_wait(&dac) == 0);        return (0);#else    (void)dac_gen_sine;        return (1);    #endif}
开发者ID:wuwx,项目名称:simba,代码行数:52,


示例29: test_print

int test_print(struct harness_t *harness_p){    struct log_object_t foo;    struct log_object_t bar;    /* Initialize the log objects. */    BTASSERT(log_object_init(&foo,                             "foo",                             LOG_UPTO(INFO)) == 0);    BTASSERT(log_object_init(&bar,                             "bar",                             LOG_UPTO(DEBUG)) == 0);    /* Write on INFO level. */    BTASSERT(log_object_print(&foo, LOG_INFO, FSTR("x = %d/r/n"), 1) == 1);    BTASSERT(log_object_print(&bar, LOG_INFO, FSTR("y = %d/r/n"), 2) == 1);    /* Write on DEBUG level. */    BTASSERT(log_object_print(&foo, LOG_DEBUG, FSTR("m = %d/r/n"), 3) == 0);    BTASSERT(log_object_print(&bar, LOG_DEBUG, FSTR("n = %d/r/n"), 4) == 1);    /* Write using the thread log mask instead of the log object       mask. */    BTASSERT(log_object_print(NULL, LOG_DEBUG, FSTR("k = %d/r/n"), 5) == 0);    BTASSERT(log_object_print(NULL, LOG_ERROR, FSTR("l = %d/r/n"), 6) == 1);    return (0);}
开发者ID:wuwx,项目名称:simba,代码行数:28,



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


C++ BTC_PRINT函数代码示例
C++ BS_End函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。