Beispiel #1
0
void check2(string str, string delim) {
	strsplit_out *out = strsplit(str, delim, false);

	strsplit_out *out2 = strsplit(str, delim, true);
	check_compressed(out2);
	check_splits_similar(out, out2);
	strsplit_free(out2);

	assert(out != NULL);
	assert(out->count > 0);
	assert(out->strings != NULL);

	char outs[strlen(str) + 2];
	outs[strlen(str) + 1] = '\2';
	strmov(outs, sizeof(outs) / sizeof(char), out->strings[0]);
	for (ulen i = 1; i < out->count; i++) {
		strapnd(outs, sizeof(outs) / sizeof(char), delim);
		strapnd(outs, sizeof(outs) / sizeof(char), out->strings[i]);
	}

	assert(outs[strlen(str)] == '\0');
	assert(outs[strlen(str) + 1] == '\2');
	assert(streq(str, outs));

	strsplit_free(out);
}
Beispiel #2
0
static void test_min_compress_size(void) {
        /* Note that XZ will actually fail to compress anything under 80 bytes, so you have to choose the limits
         * carefully */

        /* DEFAULT_MIN_COMPRESS_SIZE is 512 */
        assert_se(!check_compressed((uint64_t) -1, 255));
        assert_se(check_compressed((uint64_t) -1, 513));

        /* compress everything */
        assert_se(check_compressed(0, 96));
        assert_se(check_compressed(8, 96));

        /* Ensure we don't try to compress less than 8 bytes */
        assert_se(!check_compressed(0, 7));

        /* check boundary conditions */
        assert_se(check_compressed(256, 256));
        assert_se(!check_compressed(256, 255));
}