Coverage Report

Created: 2025-10-24 06:54

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/icu/icu4c/source/test/fuzzer/unicodeset_fuzzer.cpp
Line
Count
Source
1
// © 2019 and later: Unicode, Inc. and others.
2
// License & terms of use: http://www.unicode.org/copyright.html
3
4
#include <cstring>
5
6
#include "fuzzer_utils.h"
7
#include "unicode/coll.h"
8
#include "unicode/localpointer.h"
9
#include "unicode/uniset.h"
10
11
IcuEnvironment* env = new IcuEnvironment();
12
13
40.6k
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
14
40.6k
  UErrorCode status = U_ZERO_ERROR;
15
16
40.6k
  size_t unistr_size = size/2;
17
40.6k
  std::unique_ptr<char16_t[]> fuzzbuff(new char16_t[unistr_size]);
18
40.6k
  std::memcpy(fuzzbuff.get(), data, unistr_size * 2);
19
40.6k
  icu::UnicodeString fuzzstr(false, fuzzbuff.get(), unistr_size);
20
21
40.6k
  icu::LocalPointer<icu::UnicodeSet> set(
22
40.6k
      new icu::UnicodeSet(fuzzstr, status));
23
24
40.6k
  status = U_ZERO_ERROR;
25
26
40.6k
  set.adoptInstead(new icu::UnicodeSet());
27
40.6k
  set->applyPattern (fuzzstr, status);
28
29
40.6k
  set.adoptInstead(new icu::UnicodeSet());
30
40.6k
  set->addAll(fuzzstr);
31
32
40.6k
  set.adoptInstead(new icu::UnicodeSet());
33
40.6k
  set->add(fuzzstr);
34
35
40.6k
  set.adoptInstead(new icu::UnicodeSet());
36
40.6k
  set->retainAll(fuzzstr);
37
38
40.6k
  set.adoptInstead(new icu::UnicodeSet());
39
40.6k
  set->complementAll(fuzzstr);
40
41
40.6k
  set.adoptInstead(new icu::UnicodeSet());
42
40.6k
  set->removeAll(fuzzstr);
43
44
40.6k
  set.adoptInstead(new icu::UnicodeSet());
45
40.6k
  set->retain(fuzzstr);
46
47
40.6k
  set.adoptInstead(new icu::UnicodeSet());
48
40.6k
  set->remove(fuzzstr);
49
50
40.6k
  set.adoptInstead(new icu::UnicodeSet());
51
40.6k
  set->complement(fuzzstr);
52
53
40.6k
  set.adoptInstead(icu::UnicodeSet::createFrom(fuzzstr));
54
55
40.6k
  set.adoptInstead(icu::UnicodeSet::createFromAll(fuzzstr));
56
40.6k
  return 0;
57
40.6k
}