1#ifndef CODEX_BASE64_TEST_COMMON_H
2#define CODEX_BASE64_TEST_COMMON_H
16 begin(ret), begin(ret) +
static_cast<std::ptrdiff_t
>(
n),
17 std::bind_front(std::uniform_int_distribution<char>{}, *gen));
23 QFETCH(std::size_t, dec_size);
26 return std::tuple(dec_size, enc_size,
rnd_vec(gen, dec_size));
29template<
typename T,
typename C,
bool B>
31 const auto [dec_size, enc_size, input_v] =
gen_input(gen);
32 const std::string_view input = {input_v.data(), dec_size};
33 auto output = std::vector<char>(enc_size);
35 QBENCHMARK { T::encode(input, output.data()); }
37 T::encode(input, output.data());
41template<
typename T,
typename C,
bool B>
43 const auto [dec_size, enc_size, input_v] =
gen_input(gen);
44 const std::string_view input = {input_v.data(), dec_size};
45 auto encoded = std::vector<char>(enc_size);
46 T::encode(input, encoded.data());
47 auto output = std::vector<char>(input_v.size());
49 QBENCHMARK { T::decode({encoded.data(), enc_size}, output.data()); }
51 T::decode({encoded.data(), enc_size}, output.data());
56void check_encode(std::string_view input,
const std::vector<char> &output) {
57 const auto n = output.size();
58 auto expected = std::vector<char>(
n);
59 F(input, expected.data());
61 std::string_view(output.data(),
n),
62 std::string_view(expected.data(),
n));
67 std::string_view input, std::string_view encoded,
68 const std::vector<char> &output
70 const auto n = input.size();
71 auto expected = std::vector<char>(
n);
73 static_cast<const void*
>(expected.data() +
n),
74 static_cast<const void*
>(F(encoded, expected.data())));
76 std::string_view(output.data(),
n),
77 std::string_view(expected.data(),
n));
constexpr std::size_t output_size(std::size_t n)
Calculates the size of the buffer required for the output, rounding up.
Definition cmd.hpp:48
constexpr T round_to_block_size(T n)
Rounds an integral value to a given block size, always towards infinity.
Definition cmd.hpp:44
std::vector< char > rnd_vec(T *gen, std::size_t n)
Definition common.hpp:13
void check_decode(std::string_view input, std::string_view encoded, const std::vector< char > &output)
Definition common.hpp:66
void encode_test(auto *gen)
Definition common.hpp:30
auto gen_input(T *gen)
Definition common.hpp:22
void check_encode(std::string_view input, const std::vector< char > &output)
Definition common.hpp:56
void decode_test(auto *gen)
Definition common.hpp:42
void * B
Definition ooc.c:153
codex::refl::field_tuple_t< E > T
Definition soa.cpp:9