Ejemplo n.º 1
0
    static void test_decoder(uint32_t max_symbols, uint32_t max_symbol_size,
        codec code, field field)
    {
        decoder_factory decoder_factory(
            code,
            field,
            max_symbols,
            max_symbol_size);

        decoder decoder = decoder_factory.build();
        test_coder(decoder, max_symbols, max_symbol_size, code);

        // Decoder methods
        // Some codecs do not provide write_payload, i.e. recoding
        if (code == codec::seed || code == codec::sparse_seed ||
            code == codec::fulcrum || code == codec::reed_solomon)
        {
            EXPECT_FALSE(decoder.has_write_payload());
        }
        else
        {
            EXPECT_TRUE(decoder.has_write_payload());
        }

        EXPECT_GE(0U, decoder.symbols_uncoded());
        EXPECT_GE(0U, decoder.symbols_partially_decoded());

        if (code == codec::on_the_fly ||
            code == codec::sliding_window)
        {
            EXPECT_TRUE(decoder.has_partial_decoding_interface());
            EXPECT_FALSE(decoder.is_partially_complete());
            for (uint32_t i = 0; i < decoder.symbols(); ++i)
            {
                EXPECT_FALSE(decoder.is_symbol_pivot(i));
            }
        }
        else if (code == codec::full_vector ||
                 code == codec::perpetual)
        {
            EXPECT_FALSE(decoder.has_partial_decoding_interface());
        }
    }
Ejemplo n.º 2
0
static void test_decoder(uint32_t symbols, uint32_t symbol_size,
                         int32_t codec, int32_t finite_field)
{
    kodoc_factory_t decoder_factory = kodoc_new_decoder_factory(
        codec, finite_field, symbols, symbol_size);

    kodoc_coder_t decoder = kodoc_factory_build_coder(decoder_factory);

    // Coder methods
    test_coder(decoder, symbols, symbol_size, codec);

    // Decoder methods
    // Some codecs do not provide write_payload, i.e. recoding
    if (codec == kodoc_seed || codec == kodoc_sparse_seed ||
        codec == kodoc_fulcrum || codec == kodoc_reed_solomon)
    {
        EXPECT_TRUE(kodoc_has_write_payload(decoder) == 0);
    }
    else
    {
        EXPECT_TRUE(kodoc_has_write_payload(decoder) != 0);
    }

    EXPECT_EQ(0U, kodoc_symbols_uncoded(decoder));
    EXPECT_EQ(0U, kodoc_symbols_partially_decoded(decoder));

    if (codec == kodoc_on_the_fly ||
        codec == kodoc_sliding_window)
    {
        EXPECT_TRUE(kodoc_has_partial_decoding_interface(decoder) != 0);
    }
    else if (codec == kodoc_full_vector)
    {
        EXPECT_TRUE(kodoc_has_partial_decoding_interface(decoder) == 0);
    }

    kodoc_delete_coder(decoder);
    kodoc_delete_factory(decoder_factory);
}