File: random_utf32.cpp

package info (click to toggle)
simdutf 7.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,968 kB
  • sloc: cpp: 59,437; ansic: 14,080; python: 3,135; sh: 311; makefile: 12
file content (42 lines) | stat: -rw-r--r-- 744 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "random_utf32.h"

#include <stdexcept>
#include <vector>

namespace simdutf {
namespace tests {
namespace helpers {

std::vector<char32_t> random_utf32::generate(size_t size) {

  std::vector<char32_t> result;
  result.reserve(size);

  size_t count{0};
  for (; count < size; count++) {
    const uint32_t value = generate();
    result.push_back(value);
  }

  return result;
}

std::vector<char32_t> random_utf32::generate(size_t size, long seed) {
  gen.seed(seed);
  return generate(size);
}

uint32_t random_utf32::generate() {
  switch (range(gen)) {
  case 0:
    return first_range(gen);
  case 1:
    return second_range(gen);
  default:
    abort();
  }
}

} // namespace helpers
} // namespace tests
} // namespace simdutf