Skip to content

Commit

Permalink
Remove filter in avif_fuzztest_properties
Browse files Browse the repository at this point in the history
Avoid failures due to "Ineffective use of Filter()".
  • Loading branch information
y-guyon committed Jan 17, 2025
1 parent 49729e4 commit db37f71
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions tests/gtest/avif_fuzztest_properties.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ void EncodeDecode(ImagePtr image, EncoderPtr encoder, DecoderPtr decoder,
ASSERT_EQ(
avifImageAddUUIDProperty(image.get(), testProp.uuid.data(),
testProp.body.data(), testProp.body.size()),
AVIF_RESULT_OK);
avifIsValidUUID(testProp.uuid.data()) ? AVIF_RESULT_OK
: AVIF_RESULT_INVALID_ARGUMENT);
} else {
ASSERT_EQ(avifImageAddOpaqueProperty(image.get(), testProp.fourcc.data(),
testProp.body.data(),
testProp.body.size()),
AVIF_RESULT_OK);
avifIsKnownPropertyType(testProp.fourcc.data())
? AVIF_RESULT_INVALID_ARGUMENT
: AVIF_RESULT_OK);
}
}

Expand Down Expand Up @@ -74,22 +77,14 @@ inline auto ArbitraryProp() {
auto fourcc = fuzztest::Arbitrary<std::array<uint8_t, 4>>();
auto uuid = fuzztest::Arbitrary<std::array<uint8_t, 16>>(); // ignored
auto body = fuzztest::Arbitrary<std::vector<uint8_t>>();
// Don't return known properties.
return fuzztest::Filter(
[](const TestProp& prop) {
return !avifIsKnownPropertyType(prop.fourcc.data());
},
fuzztest::StructOf<TestProp>(fourcc, uuid, body));
return fuzztest::StructOf<TestProp>(fourcc, uuid, body);
}

inline auto ArbitraryUUIDProp() {
auto fourcc = fuzztest::Just(std::array<uint8_t, 4>{'u', 'u', 'i', 'd'});
auto uuid = fuzztest::Arbitrary<std::array<uint8_t, 16>>();
auto body = fuzztest::Arbitrary<std::vector<uint8_t>>();
// Don't use invalid UUIDs.
return fuzztest::Filter(
[](const TestProp& prop) { return avifIsValidUUID(prop.uuid.data()); },
fuzztest::StructOf<TestProp>(fourcc, uuid, body));
return fuzztest::StructOf<TestProp>(fourcc, uuid, body);
}

inline auto ArbitraryProps() {
Expand Down

0 comments on commit db37f71

Please sign in to comment.