Exemplo n.º 1
0
inline void test_recoding_relay()
{
    recoding_parameters param;
    param.m_max_symbols = 32;
    param.m_max_symbol_size = 1600;
    param.m_symbols = param.m_max_symbols;
    param.m_symbol_size = param.m_max_symbol_size;

    test_recoding_relay<Encoder,Decoder>(param);

    param.m_max_symbols = 1;
    param.m_max_symbol_size = 1600;
    param.m_symbols = param.m_max_symbols;
    param.m_symbol_size = param.m_max_symbol_size;

    test_recoding_relay<Encoder,Decoder>(param);

    param.m_max_symbols = 8;
    param.m_max_symbol_size = 8;
    param.m_symbols = param.m_max_symbols;
    param.m_symbol_size = param.m_max_symbol_size;

    test_recoding_relay<Encoder,Decoder>(param);

    param.m_max_symbols = rand_symbols();
    param.m_max_symbol_size = rand_symbol_size();
    param.m_symbols = rand_symbols(param.m_max_symbols);
    param.m_symbol_size = rand_symbol_size(param.m_max_symbol_size);

    test_recoding_relay<Encoder,Decoder>(param);
}
Exemplo n.º 2
0
TEST(test_decoder, invoke_api)
{
    uint32_t symbols = rand_symbols();
    uint32_t symbol_size = rand_symbol_size();

    test_combinations(test_decoder, symbols, symbol_size);
}
Exemplo n.º 3
0
inline void
invoke_reuse(uint32_t symbols, uint32_t symbol_size)
{
    // Common setting
    typename Encoder::factory encoder_factory(symbols, symbol_size);
    typename Decoder::factory decoder_factory(symbols, symbol_size);

    for(uint32_t i = 0; i < 4; ++i)
    {
        uint32_t coders = rand_nonzero(10);

        std::vector<typename Encoder::pointer> encoders;
        std::vector<typename Decoder::pointer> decoders;

        for(uint32_t j = 0; j < coders; ++j)
        {
            encoders.push_back(encoder_factory.build());
            decoders.push_back(decoder_factory.build());

        }

        for(uint32_t j = 0; j < coders; ++j)
        {
            invoke_reuse_helper(encoders[j], decoders[j]);
        }

    }

    return;

    // Test with differing symbols and symbol sizes
    for(uint32_t i = 0; i < 4; ++i)
    {
        uint32_t coders = rand_nonzero(10);

        std::vector<typename Encoder::pointer> encoders;
        std::vector<typename Decoder::pointer> decoders;

        for(uint32_t j = 0; j < coders; ++j)
        {
            uint32_t s = rand_symbols(encoder_factory.max_symbols());
            uint32_t l = rand_symbol_size(encoder_factory.max_symbol_size());

            encoder_factory.set_symbols(s);
            encoder_factory.set_symbol_size(l);
            decoder_factory.set_symbols(s);
            decoder_factory.set_symbol_size(l);

            encoders.push_back(encoder_factory.build());
            decoders.push_back(decoder_factory.build());
        }

        for(uint32_t j = 0; j < coders; ++j)
        {
            invoke_reuse_helper(encoders[j], decoders[j]);
        }

    }

}
Exemplo n.º 4
0
TEST(test_encoder_factory, invoke_api)
{
    // Make sure that we can lower these values in the test
    uint32_t max_symbols = rand_symbols() + 1;
    uint32_t max_symbol_size = rand_symbol_size() + 4;

    test_combinations(test_encoder_factory, max_symbols, max_symbol_size);
}
Exemplo n.º 5
0
TEST(test_sliding_window_codes, basic_api)
{
    if (kodoc_has_codec(kodoc_sliding_window) == false)
        return;

    uint32_t max_symbols = rand_symbols();
    uint32_t max_symbol_size = rand_symbol_size();

    test_basic_api(kodoc_sliding_window, max_symbols, max_symbol_size);
}
Exemplo n.º 6
0
inline void test_on_the_fly_systematic()
{
    test_on_the_fly_systematic<Encoder, Decoder>(32, 1600);
    test_on_the_fly_systematic<Encoder, Decoder>(1, 1600);

    uint32_t symbols = rand_symbols();
    uint32_t symbol_size = rand_symbol_size();

    test_on_the_fly_systematic<Encoder, Decoder>(symbols, symbol_size);
}
Exemplo n.º 7
0
inline void test_reuse_incomplete()
{
    test_reuse_incomplete<Encoder, Decoder>(1, 1600);
    test_reuse_incomplete<Encoder, Decoder>(32, 1600);

    uint32_t symbols = rand_symbols();
    uint32_t symbol_size = rand_symbol_size();

    test_reuse_incomplete<Encoder, Decoder>(symbols, symbol_size);
}
Exemplo n.º 8
0
TEST(test_on_the_fly_codes, basic_api)
{
    if (kodoc_has_codec(kodoc_on_the_fly) == false)
        return;

    uint32_t max_symbols = rand_symbols();
    uint32_t max_symbol_size = rand_symbol_size();

    test_basic_api(kodoc_on_the_fly, max_symbols, max_symbol_size);
}
Exemplo n.º 9
0
inline void test_basic_api()
{

    test_basic_api<Encoder, Decoder>(32, 1600);
    test_basic_api<Encoder, Decoder>(1, 1600);

    uint32_t symbols = rand_symbols();
    uint32_t symbol_size = rand_symbol_size();

    test_basic_api<Encoder, Decoder>(symbols, symbol_size);
}
Exemplo n.º 10
0
/// Run the tests typical coefficients stack
TEST(TestCoefficientGenerator, test_uniform_generator_stack)
{
    uint32_t symbols = rand_symbols();
    uint32_t symbol_size = rand_symbol_size();

    // API tests:
    run_test<
        kodo::uniform_generator_stack,
        api_generate>(symbols, symbol_size);

    run_test<
        kodo::uniform_generator_stack_pool,
        api_generate>(symbols, symbol_size);
}
Exemplo n.º 11
0
TEST(test_sliding_window_codes, invoke_api)
{
    if (kodoc_has_codec(kodoc_sliding_window) == false)
        return;

    uint32_t max_symbols = rand_symbols();
    uint32_t max_symbol_size = rand_symbol_size();

    test_sliding_window(max_symbols, max_symbol_size, kodoc_binary);

    test_sliding_window(max_symbols, max_symbol_size, kodoc_binary4);

    test_sliding_window(max_symbols, max_symbol_size, kodoc_binary8);
}
Exemplo n.º 12
0
/// Tests:
///  - object_encoder::encoders() const
///  - object_decoder::decoders() const
///  - object_encoder::build(uint32_t)
///  - object_decoder::build(uint32_t)
TEST(TestObjectCoder, construct_and_invoke_the_basic_api)
{
    test_object_coders(32, 1600, 2);
    test_object_coders(1, 1600, 2);

    uint32_t symbols = rand_symbols();
    uint32_t symbol_size = rand_symbol_size();

    // Multiplies the data to be encoded so that the object encoder
    // is expected to contain multiplier encoders.
    uint32_t multiplier = rand_nonzero(10);

    test_object_coders(symbols, symbol_size, multiplier);
}
Exemplo n.º 13
0
TEST(test_on_the_fly_codes, invoke_api)
{
    if (kodoc_has_codec(kodoc_on_the_fly) == false)
        return;

    uint32_t max_symbols = rand_symbols();
    uint32_t max_symbol_size = rand_symbol_size();

    test_on_the_fly(max_symbols, max_symbol_size, kodoc_binary);

    test_on_the_fly(max_symbols, max_symbol_size, kodoc_binary4);

    test_on_the_fly(max_symbols, max_symbol_size, kodoc_binary8);
}
Exemplo n.º 14
0
TEST(TestRandomAnnexCoder, construct_and_invoke_the_basic_api)
{
    test_random_annex_coders(32, 1600, 2);

    srand(static_cast<uint32_t>(time(0)));

    uint32_t symbols = rand_symbols();
    uint32_t symbol_size = rand_symbol_size();

    // Multiplies the data to be encoded so that the object encoder
    // is expected to contain multiplier encoders.
    uint32_t multiplier = (rand() % 10) + 1;

    test_random_annex_coders(symbols, symbol_size, multiplier);
}
Exemplo n.º 15
0
TEST(TestReedSolomonCodes, test_encode_decode)
{
    {
        kodo::rs_encoder<fifi::binary8>::factory encoder_factory(255, 1600);
        kodo::rs_decoder<fifi::binary8>::factory decoder_factory(255, 1600);

        uint32_t symbols = rand_symbols(255);
        uint32_t symbol_size = rand_symbol_size();

        encoder_factory.set_symbols(symbols);
        encoder_factory.set_symbol_size(symbol_size);

        decoder_factory.set_symbols(symbols);
        decoder_factory.set_symbol_size(symbol_size);

        auto encoder = encoder_factory.build();
        auto decoder = decoder_factory.build();

        // Encode/decode operations
        EXPECT_TRUE(encoder->payload_size() == decoder->payload_size());

        std::vector<uint8_t> payload(encoder->payload_size());
        std::vector<uint8_t> data_in = random_vector(encoder->block_size());

        encoder->set_symbols(sak::storage(data_in));

        uint32_t symbol_count = 0;
        while( !decoder->is_complete() )
        {
            encoder->encode( &payload[0] );
            decoder->decode( &payload[0] );
            ++symbol_count;
        }

        // A reed solomon code should be able to decode
        // with exactly k symbols
        EXPECT_EQ(symbol_count, symbols);

        std::vector<uint8_t> data_out(decoder->block_size(), '\0');
        decoder->copy_symbols(sak::storage(data_out));

        EXPECT_TRUE(std::equal(data_out.begin(),
                               data_out.end(),
                               data_in.begin()));

    }

}