• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ BTASSERT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了BTASSERT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c


示例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,代码来源:main.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ BTC_PRINT函数代码示例发布时间:2022-05-30
下一篇:
C++ BS_End函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap