diff options
Diffstat (limited to 'fuzz/FuzzParsePath.cpp')
-rw-r--r-- | fuzz/FuzzParsePath.cpp | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/fuzz/FuzzParsePath.cpp b/fuzz/FuzzParsePath.cpp index 6eb7f3b713..1a597d87a0 100644 --- a/fuzz/FuzzParsePath.cpp +++ b/fuzz/FuzzParsePath.cpp @@ -39,48 +39,44 @@ static void add_white(Fuzz* fuzz, SkString* atom) { atom->append(" "); return; } - int reps = fuzz->nextRangeU(0, 2); + int reps = fuzz->nextRange(0, 2); for (int rep = 0; rep < reps; ++rep) { - int index = fuzz->nextRangeU(0, (int) SK_ARRAY_COUNT(gWhiteSpace) - 1); + int index = fuzz->nextRange(0, (int) SK_ARRAY_COUNT(gWhiteSpace) - 1); if (gWhiteSpace[index]) { atom->append(&gWhiteSpace[index], 1); } } } +static void add_some_white(Fuzz* fuzz, SkString* atom) { + for(int i = 0; i < 10; i++) { + add_white(fuzz, atom); + } +} + static void add_comma(Fuzz* fuzz, SkString* atom) { if (gEasy) { atom->append(","); return; } - size_t count = atom->size(); add_white(fuzz, atom); - if (fuzz->nextBool()) { + if (fuzz->next<bool>()) { atom->append(","); } - do { - add_white(fuzz, atom); - } while (count == atom->size()); -} - -static void add_some_white(Fuzz* fuzz, SkString* atom) { - size_t count = atom->size(); - do { - add_white(fuzz, atom); - } while (count == atom->size()); + add_some_white(fuzz, atom); } SkString MakeRandomParsePathPiece(Fuzz* fuzz) { SkString atom; - int index = fuzz->nextRangeU(0, (int) SK_ARRAY_COUNT(gLegal) - 1); + int index = fuzz->nextRange(0, (int) SK_ARRAY_COUNT(gLegal) - 1); const Legal& legal = gLegal[index]; gEasy ? atom.append("\n") : add_white(fuzz, &atom); - char symbol = legal.fSymbol | (fuzz->nextBool() ? 0x20 : 0); + char symbol = legal.fSymbol | (fuzz->next<bool>() ? 0x20 : 0); atom.append(&symbol, 1); - int reps = fuzz->nextRangeU(1, 3); + int reps = fuzz->nextRange(1, 3); for (int rep = 0; rep < reps; ++rep) { for (int index = 0; index < legal.fScalars; ++index) { - SkScalar coord = fuzz->nextRangeF(0, 100); + SkScalar coord = fuzz->nextRange(0.0f, 100.0f); add_white(fuzz, &atom); atom.appendScalar(coord); if (rep < reps - 1 && index < legal.fScalars - 1) { @@ -89,11 +85,11 @@ SkString MakeRandomParsePathPiece(Fuzz* fuzz) { add_some_white(fuzz, &atom); } if ('A' == legal.fSymbol && 1 == index) { - atom.appendScalar(fuzz->nextRangeF(-720, 720)); + atom.appendScalar(fuzz->nextRange(-720.0f, 720.0f)); add_comma(fuzz, &atom); - atom.appendU32(fuzz->nextRangeU(0, 1)); + atom.appendU32(fuzz->nextRange(0, 1)); add_comma(fuzz, &atom); - atom.appendU32(fuzz->nextRangeU(0, 1)); + atom.appendU32(fuzz->nextRange(0, 1)); add_comma(fuzz, &atom); } } @@ -104,12 +100,12 @@ SkString MakeRandomParsePathPiece(Fuzz* fuzz) { DEF_FUZZ(ParsePath, fuzz) { SkPath path; SkString spec; - uint32_t count = fuzz->nextRangeU(0, 40); + uint32_t count = fuzz->nextRange(0, 40); for (uint32_t i = 0; i < count; ++i) { spec.append(MakeRandomParsePathPiece(fuzz)); } SkDebugf("SkParsePath::FromSVGString(%s, &path);\n",spec.c_str()); if (!SkParsePath::FromSVGString(spec.c_str(), &path)){ - fuzz->signalBug(); + SkDebugf("Could not decode path\n"); } } |