Exemplo n.º 1
0
int bt_piecedb_add(bt_piecedb_t * db, unsigned int npieces)
{
    unsigned int idx, len;

    /* get space for this block of pieces */
    chunky_get_incomplete(priv(db)->space, &idx, &len, npieces);
    assert(len == npieces);
    return bt_piecedb_add_at_idx(db, npieces, idx);
}
void Test_chunkybar_GetIncompleteWithLenUnderBoundary(
    CuTest * tc
)
{
    void *prog = chunky_new(100);

    unsigned int len, offset;

    chunky_get_incomplete(prog, &offset, &len, 200);
    CuAssertTrue(tc, 100 == len);
    chunky_free(prog);
}
void Test_chunkybar_GetIncomplete(
    CuTest * tc
)
{
    void *prog;

    prog = chunky_new(100);

    unsigned int len, offset;

    chunky_get_incomplete(prog, &offset, &len, 32);

    CuAssertTrue(tc, offset == 0);
    CuAssertTrue(tc, len == 32);
    chunky_free(prog);
}
void Test_chunkybar_GetIncomplete3(
    CuTest * tc
)
{
    void *prog;

    prog = chunky_new(100);

    unsigned int len, offset;

    chunky_mark_complete(prog, 25, 50);

    CuAssertTrue(tc, 1 == chunky_get_num_chunks(prog));

    chunky_get_incomplete(prog, &offset, &len, 32);

    CuAssertTrue(tc, offset == 0);
    CuAssertTrue(tc, len == 25);
    chunky_free(prog);
}