TEST pseudorandom_data_should_match(uint32_t size, uint32_t seed, cfg_info *cfg) {
    uint8_t input[size];
    if (cfg->log_lvl > 0) {
        printf("\n-- size %u, seed %u, input buf %u\n",
            size, seed, cfg->decoder_input_buffer_size);
    }
    fill_with_pseudorandom_letters(input, size, seed);
    return compress_and_expand_and_check(input, size, cfg);
}
TEST data_without_duplication_should_match() {
    uint8_t input[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                       'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                       's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
    cfg_info cfg;
    cfg.log_lvl = 0;
    cfg.window_sz2 = 8;
    cfg.lookahead_sz2 = 3;
    cfg.decoder_input_buffer_size = 256;
    return compress_and_expand_and_check(input, sizeof(input), &cfg);
}
TEST small_input_buffer_should_not_impact_decoder_correctness() {
    int size = 5;
    uint8_t input[size];
    cfg_info cfg;
    cfg.log_lvl = 0;
    cfg.window_sz2 = 8;
    cfg.lookahead_sz2 = 3;
    cfg.decoder_input_buffer_size = 5;
    for (uint16_t i=0; i<size; i++) input[i] = 'a' + (i % 26);
    if (compress_and_expand_and_check(input, size, &cfg) != 0) return -1;
    PASS();
}
TEST data_with_simple_repetition_should_compress_and_decompress_properly() {
    uint8_t input[] = {'a', 'b', 'c', 'a', 'b', 'c', 'd', 'a', 'b',
                       'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'f',
                       'a', 'b', 'c', 'd', 'e', 'f', 'g', 'a', 'b',
                       'c', 'd', 'e', 'f', 'g', 'h'};
    cfg_info cfg;
    cfg.log_lvl = 0;
    cfg.window_sz2 = 8;
    cfg.lookahead_sz2 = 3;
    cfg.decoder_input_buffer_size = 256;
    return compress_and_expand_and_check(input, sizeof(input), &cfg);
}
TEST sixty_four_k() {
    /* Regression: An input buffer of 64k should not cause an
     * overflow that leads to an infinite loop. */
    uint32_t size = 64 * 1024;
    uint32_t seed = 1;
    uint8_t input[size];
    fill_with_pseudorandom_letters(input, size, seed);
    cfg_info cfg;
    cfg.log_lvl = 0;
    cfg.window_sz2 = 8;
    cfg.lookahead_sz2 = 3;
    cfg.decoder_input_buffer_size = 64;
    return compress_and_expand_and_check(input, size, &cfg);
}
TEST regression_backreference_counters_should_not_roll_over() {
    /* Searching was scanning the entire context buffer, not just
     * the maximum range addressable by the backref index.*/
    uint32_t size = 337;
    uint32_t seed = 3;
    uint8_t input[size];
    fill_with_pseudorandom_letters(input, size, seed);
    cfg_info cfg;
    cfg.log_lvl = 0;
    cfg.window_sz2 = 8;
    cfg.lookahead_sz2 = 3;
    cfg.decoder_input_buffer_size = 64; // 1
    return compress_and_expand_and_check(input, size, &cfg);
}
TEST regression_index_fail() {
    /* Failured when indexed, cause unknown.
     *
     * This has something to do with bad data at the very last
     * byte being indexed, due to spillover. */
    uint32_t size = 507;
    uint32_t seed = 3;
    uint8_t input[size];
    fill_with_pseudorandom_letters(input, size, seed);
    cfg_info cfg;
    cfg.log_lvl = 0;
    cfg.window_sz2 = 8;
    cfg.lookahead_sz2 = 3;
    cfg.decoder_input_buffer_size = 64;
    return compress_and_expand_and_check(input, size, &cfg);
}
Exemplo n.º 8
0
TEST pseudorandom_data_should_match(uint32_t size, uint32_t seed) {
    uint8_t input[size];
    fill_with_pseudorandom_letters(input, size, seed);
    return compress_and_expand_and_check(input, size, 0);
}
Exemplo n.º 9
0
Arquivo: main.c Projeto: JulianYG/WNR
int pseudorandom_data_should_match(uint32_t size) {
    uint8_t input[size];
    fill_with_patient_data(input,size);
    return compress_and_expand_and_check(input, size);
}