Flutter Engine
The Flutter Engine
Functions
FuzzQuadRoots.cpp File Reference
#include "fuzz/Fuzz.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkFloatingPoint.h"
#include "src/base/SkCubics.h"
#include "src/base/SkQuads.h"
#include "src/base/SkUtils.h"
#include <cmath>

Go to the source code of this file.

Functions

static void fuzz_quad_real_roots (double A, double B, double C)
 
 DEF_FUZZ (QuadRoots, fuzz)
 

Function Documentation

◆ DEF_FUZZ()

DEF_FUZZ ( QuadRoots  ,
fuzz   
)

Definition at line 36 of file FuzzQuadRoots.cpp.

36 {
37 double A, B, C;
38 fuzz->next(&A);
39 fuzz->next(&B);
40 fuzz->next(&C);
41
42 // Uncomment for easy test case creation
43// SkDebugf("A %16e (0x%lx) B %16e (0x%lx) C %16e (0x%lx)\n",
44// A, sk_bit_cast<uint64_t>(A), B, sk_bit_cast<uint64_t>(B),
45// C, sk_bit_cast<uint64_t>(C));
46
48}
static void fuzz_quad_real_roots(double A, double B, double C)
#define C(TEST_CATEGORY)
Definition: colrv1.cpp:248
#define B

◆ fuzz_quad_real_roots()

static void fuzz_quad_real_roots ( double  A,
double  B,
double  C 
)
static

Definition at line 17 of file FuzzQuadRoots.cpp.

17 {
18 double roots[2];
19 const int numSolutions = SkQuads::RootsReal(A, B, C, roots);
20 SkASSERT_RELEASE(numSolutions >= 0 && numSolutions <= 2);
21 for (int i = 0; i < numSolutions; i++) {
23 // You may be tempted to add assertions that plug the provided solutions into
24 // the quadratic equation and verify that the result is zero. Be advised
25 // that the fuzzer is very good at finding float values that result in
26 // seemingly arbitrarily large errors, due to the imprecision of floating
27 // point math. Unless the input range is sufficiently small, such an
28 // effort seems fruitless.
29 }
30 if (numSolutions == 2) {
31 // Roots should not be duplicated
33 }
34}
#define SkASSERT_RELEASE(cond)
Definition: SkAssert.h:100
bool sk_doubles_nearly_equal_ulps(double a, double b, uint8_t maxUlpsDiff=16)
static int RootsReal(double A, double B, double C, double solution[2])
Definition: SkQuads.cpp:135
SINT bool isfinite(const Vec< N, T > &v)
Definition: SkVx.h:1003