File: test_utilities.hpp

package info (click to toggle)
jsoncons 1.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 18,276 kB
  • sloc: cpp: 143,266; sh: 34; makefile: 8
file content (21 lines) | stat: -rw-r--r-- 445 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef JSONCONS_TESTS_TEST_UTILITIES_HPP
#define JSONCONS_TESTS_TEST_UTILITIES_HPP

#include <random>
#include <string>
#include <cstddef>

template <typename Generator>
std::string random_binary_string(Generator& gen, std::size_t n)
{
  std::string s;
  s.reserve(n);
  for (std::size_t i = 0; i < n; ++i)
  {
      auto c = static_cast<char>(std::uniform_int_distribution<int>('0', '1')(gen));
      s.push_back(c);
  }
  return s;
}

#endif