File: count_utf16le.cpp

package info (click to toggle)
simdutf 7.7.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,244 kB
  • sloc: cpp: 60,074; ansic: 14,226; python: 3,364; sh: 321; makefile: 12
file content (45 lines) | stat: -rw-r--r-- 1,251 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
43
44
45
#include "simdutf.h"

#include <array>

#include <tests/helpers/random_int.h>
#include <tests/helpers/random_utf16.h>
#include <tests/helpers/test.h>

namespace {
constexpr std::array<size_t, 9> input_size{7,   12,  16,  64,  67,
                                           128, 256, 511, 1000};

} // namespace

TEST_LOOP(count_just_one_word) {
  simdutf::tests::helpers::random_utf16 random(seed, 1, 0);

  for (size_t size : input_size) {
    const auto generated = random.generate_counted_le(size);
    ASSERT_EQUAL(implementation.count_utf16le(generated.first.data(), size),
                 generated.second);
  }
}

TEST_LOOP(count_1_or_2_UTF16_words) {
  simdutf::tests::helpers::random_utf16 random(seed, 1, 1);

  for (size_t size : input_size) {
    auto generated = random.generate_counted_le(size);
    ASSERT_EQUAL(implementation.count_utf16le(generated.first.data(), size),
                 generated.second);
  }
}

TEST_LOOP(count_2_UTF16_words) {
  simdutf::tests::helpers::random_utf16 random(seed, 0, 1);

  for (size_t size : input_size) {
    const auto generated = random.generate_counted_le(size);
    ASSERT_EQUAL(implementation.count_utf16le(generated.first.data(), size),
                 generated.second);
  }
}

TEST_MAIN