Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/tools/fuzzing/common/FuzzingTraits.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "FuzzingTraits.h"
8
9
namespace mozilla {
10
namespace fuzzing {
11
12
/* static */
13
unsigned int
14
FuzzingTraits::Random(unsigned int aMax)
15
0
{
16
0
  MOZ_ASSERT(aMax > 0, "aMax needs to be bigger than 0");
17
0
  return static_cast<unsigned int>(random() % aMax);
18
0
}
19
20
/* static */
21
bool
22
FuzzingTraits::Sometimes(unsigned int aProbability)
23
0
{
24
0
  return FuzzingTraits::Random(aProbability) == 0;
25
0
}
26
27
/*static */
28
size_t
29
FuzzingTraits::Frequency(const size_t aSize, const uint64_t aFactor)
30
0
{
31
0
  return RandomIntegerRange<size_t>(0, ceil(float(aSize) / aFactor)) + 1;
32
0
}
33
34
} // namespace fuzzing
35
} // namespace mozilla