size_t minreq = pa_memblockq_get_minreq(bq);
size_t prebuf = pa_memblockq_get_prebuf(bq);
size_t length = pa_memblockq_get_length(bq);
- size_t missing = pa_memblockq_missing(bq);
/* base > zero */
ck_assert_int_gt(base, 0);
* length <= maxlength */
ck_assert_int_ge(length, 0);
ck_assert_int_le(length, maxlength);
-
- /* missing >= 0
- * missing <= tlength
- * minimum reported amount of missing data is minreq
- * reported amount of missing data is target length minus actual length */
- ck_assert_int_ge(missing, 0);
- ck_assert_int_le(missing, tlength);
- ck_assert((missing == 0) || (missing >= minreq));
- ck_assert((missing == 0) || (missing == tlength - length));
}
START_TEST (memchunk_from_str_test) {
/* check initial properties */
ck_assert_int_eq(pa_memblockq_is_readable(bq), false);
ck_assert_int_eq(pa_memblockq_get_length(bq), 0);
- ck_assert_int_eq(pa_memblockq_missing(bq), tlength);
ck_assert_int_eq(pa_memblockq_get_maxlength(bq), maxlength);
ck_assert_int_eq(pa_memblockq_get_tlength(bq), tlength);
ck_assert_int_eq(pa_memblockq_get_prebuf(bq), prebuf);
/* check state */
ck_assert_int_eq(pa_memblockq_get_length(bq), 32);
- ck_assert_int_eq(pa_memblockq_missing(bq), 0);
/* adjust maximum length
* This might modify tlength, prebuf, minreq, too. */
fail_unless(bq != NULL);
/* initially, the whole target length of bytes is missing */
- ck_assert_int_eq(pa_memblockq_missing(bq), tlength);
ck_assert_int_eq(pa_memblockq_pop_missing(bq), tlength);
/* add 20 bytes of data */
ck_assert_int_eq(pa_memblockq_push(bq, &data), 0);
check_queue_invariants(bq);
- /* the missing bytes are reduced, but no new missing data is reported */
- ck_assert_int_eq(pa_memblockq_missing(bq), tlength - 20);
+ /* no new missing data is reported */
ck_assert_int_eq(pa_memblockq_pop_missing(bq), 0);
/* fill up to 100 bytes of data */
check_queue_invariants(bq);
/* queue fill level is at target level now */
- ck_assert_int_eq(pa_memblockq_missing(bq), 0);
ck_assert_int_eq(pa_memblockq_pop_missing(bq), 0);
/* pop 40 bytes of data, down to 60 bytes fill level */
/* queue fill level is 40 bytes under target length
* This is less than minreq, so no missing data is reported */
- ck_assert_int_eq(pa_memblockq_missing(bq), 0);
ck_assert_int_eq(pa_memblockq_pop_missing(bq), 0);
/* add 30 bytes of data, up to 90 bytes fill level */
/* queue fill level is 10 bytes under target length
* This is less than minreq, so no missing data is reported. */
- ck_assert_int_eq(pa_memblockq_missing(bq), 0);
ck_assert_int_eq(pa_memblockq_pop_missing(bq), 0);
/* pop 20 bytes of data, down to 70 bytes of data */
/* queue fill level is 30 bytes under target length
* This is less than minreq, so no missing data is reported */
- ck_assert_int_eq(pa_memblockq_missing(bq), 0);
ck_assert_int_eq(pa_memblockq_pop_missing(bq), 0);
/* add 50 bytes of data, up to 120 bytes fill level */
check_queue_invariants(bq);
/* queue fill level is above target level, so no missing data is reported. */
- ck_assert_int_eq(pa_memblockq_missing(bq), 0);
ck_assert_int_eq(pa_memblockq_pop_missing(bq), 0);
/* pop 20 bytes of data, down the target level */
/* queue fill level is at target level now
* No missing data should be reported. */
- ck_assert_int_eq(pa_memblockq_missing(bq), 0);
ck_assert_int_eq(pa_memblockq_pop_missing(bq), 0);
/* cleanup */