Esempio n. 1
0
int main(int argc, char **argv)
{
    unsigned char buf[BUF_LEN];
    unsigned int i;

    for (i=1; i<=BUF_LEN; i++) {
        buf[i-1] = (i * 2) & 0xff;
    }
    i = 0;

    if (       !test_PACKET_buf_init()
            || !test_PACKET_remaining(buf)
            || !test_PACKET_get_1(buf)
            || !test_PACKET_get_4(buf)
            || !test_PACKET_get_net_2(buf)
            || !test_PACKET_get_net_3(buf)
            || !test_PACKET_get_net_4(buf)
            || !test_PACKET_get_sub_packet(buf)
            || !test_PACKET_get_bytes(buf)
            || !test_PACKET_copy_bytes(buf)
            || !test_PACKET_memdup(buf)
            || !test_PACKET_strndup()
            || !test_PACKET_forward(buf)
            || !test_PACKET_get_length_prefixed_1()
            || !test_PACKET_get_length_prefixed_2()
            || !test_PACKET_get_length_prefixed_3()) {
        return 1;
    }
    printf("PASS\n");
    return 0;
}
Esempio n. 2
0
int main(int argc, char **argv)
{
    unsigned char buf[BUF_LEN];
    unsigned int i;
    size_t start = 0;
    PACKET pkt;

    for (i=1; i<=BUF_LEN; i++) {
        buf[i-1] = (i * 2) & 0xff;
    }
    i = 0;

    if (       !PACKET_buf_init(&pkt, buf, BUF_LEN)
            || !PACKET_get_bookmark(&pkt, &start)) {
        fprintf(stderr, "setup failed\n");
        return 0;
    }

    if (       !test_PACKET_buf_init()
            || !test_PACKET_remaining(&pkt)
            || !test_PACKET_get_1(&pkt, start)
            || !test_PACKET_get_4(&pkt, start)
            || !test_PACKET_get_net_2(&pkt, start)
            || !test_PACKET_get_net_3(&pkt, start)
            || !test_PACKET_get_net_4(&pkt, start)
            || !test_PACKET_get_sub_packet(&pkt, start)
            || !test_PACKET_get_bytes(&pkt, start)
            || !test_PACKET_copy_bytes(&pkt, start)
            || !test_PACKET_move_funcs(&pkt, start)
            || !test_PACKET_get_length_prefixed_1()
            || !test_PACKET_get_length_prefixed_2()
            || !test_PACKET_get_length_prefixed_3()) {
        return 1;
    }
    printf("PASS\n");
    return 0;
}