Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Unified Diff: fuzz/fuzz.cpp

Issue 1702383003: Create ParsePath API fuzz (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fix float Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fuzz/FuzzParsePath.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fuzz/fuzz.cpp
diff --git a/fuzz/fuzz.cpp b/fuzz/fuzz.cpp
index 596000d408b380aa81bf761356bea79cb8917b10..dce9c8adbb2465ef2b3629cb75125ce5e952eb81 100644
--- a/fuzz/fuzz.cpp
+++ b/fuzz/fuzz.cpp
@@ -17,6 +17,7 @@
#include "SkPicture.h"
#include "SkStream.h"
+#include <cmath>
#include <signal.h>
#include <stdlib.h>
@@ -114,8 +115,8 @@ static void dump_png(SkBitmap bitmap) {
int fuzz_img(SkData* bytes, uint8_t scale, uint8_t mode) {
// We can scale 1x, 2x, 4x, 8x, 16x
scale = scale % 5;
- float fscale = pow(2.0f, scale);
- SkDebugf("Scaling factor: %d\n", fscale);
+ float fscale = (float)pow(2.0f, scale);
+ SkDebugf("Scaling factor: %f\n", fscale);
// We have 4 different modes of decoding, just like DM.
mode = mode % 4;
@@ -393,6 +394,31 @@ T Fuzz::nextT() {
}
uint8_t Fuzz::nextB() { return this->nextT<uint8_t >(); }
+bool Fuzz::nextBool() { return nextB()&1; }
uint32_t Fuzz::nextU() { return this->nextT<uint32_t>(); }
float Fuzz::nextF() { return this->nextT<float >(); }
+
+uint32_t Fuzz::nextRangeU(uint32_t min, uint32_t max) {
+ if (min > max) {
+ SkDebugf("Check mins and maxes (%d, %d)\n", min, max);
+ this->signalBoring();
+ }
+ uint32_t range = max - min + 1;
+ if (0 == range) {
+ return this->nextU();
+ } else {
+ return min + this->nextU() % range;
+ }
+}
+float Fuzz::nextRangeF(float min, float max) {
+ if (min > max) {
+ SkDebugf("Check mins and maxes (%f, %f)\n", min, max);
+ this->signalBoring();
+ }
+ float f = std::abs(this->nextF());
+ if (!std::isnormal(f) && f != 0.0) {
+ this->signalBoring();
+ }
+ return min + fmod(f, (max - min + 1));
+}
« no previous file with comments | « fuzz/FuzzParsePath.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698