Welcome to mirror list, hosted at ThFree Co, Russian Federation.

coder_test.hpp « coding_tests « coding - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3f72a5e0e1ad13b6368aa0faadb8f3e005a02040 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#pragma once

#include "testing/testing.hpp"
#include "coding/coder.hpp"

// TODO: void CoderRandomTest(Coder & encoder, Coder & decoder);
// TODO: void CoderTextTest(Coder & encoder, Coder & decoder);
// TODO: Test buffer overrun coder behavior.

template <typename EncoderT, typename DecoderT>
void CoderAaaaTest(EncoderT encoder, DecoderT decoder)
{
  for (int i = 1; i <= 65536; (i > 16 && (i & 3) == 1) ? i = (i & ~3) * 2 : ++i)
  {
    string data(i, 'a'), encoded, decoded;
    encoder(&data[0], data.size(), encoded);
    decoder(&encoded[0], encoded.size(), decoded);
    TEST_EQUAL(data, decoded, ());
  }
}