Skip to content

Commit

Permalink
BREAKING: junit: Use default element name in @DictionaryEntries
Browse files Browse the repository at this point in the history
This allows for cleaner syntax (`@DictionaryEntries({"a", "b"})` and
avoids introducing yet another term (`token`).
  • Loading branch information
fmeum committed Oct 18, 2023
1 parent b0bcdc1 commit b121327
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class DictionaryFuzzTests {
private static final byte[] FLAG_SHA256 =
Base64.getDecoder().decode("vCLInoVuMxJonT4UKjsMl0LPXTowkYS7t0uBpw0pRo8=");

@DictionaryEntries(tokens = {"a_", "53Cr\"3T_", "fl4G"})
@DictionaryEntries({"a_", "53Cr\"3T_", "fl4G"})
@FuzzTest
public void inlineTest(FuzzedDataProvider data)
throws NoSuchAlgorithmException, TestSuccessfulException {
Expand All @@ -54,7 +54,7 @@ public void fileTest(FuzzedDataProvider data)
}
}

@DictionaryEntries(tokens = {"a_"})
@DictionaryEntries("a_")
@DictionaryFile(resourcePath = "test2.dict")
@DictionaryFile(resourcePath = "/com/example/test3.dict")
@FuzzTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.lang.annotation.Target;

/**
* Adds the given strings to the fuzzer's dictionary. This is particularly useful for adding tokens
* Adds the given strings to the fuzzer's dictionary. This is particularly useful for adding strings
* that have special meaning in the context of your fuzz test, but are difficult for the fuzzer to
* discover automatically.
*
Expand All @@ -35,5 +35,5 @@
@Repeatable(DictionaryEntriesList.class)
public @interface DictionaryEntries {
/** Individual strings to add to the fuzzer dictionary. */
String[] tokens();
String[] value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private static Optional<Path> createDictionaryFile(
*/
private static Stream<String> getInlineTokens(List<DictionaryEntries> inline) {
return inline.stream()
.map(DictionaryEntries::tokens)
.map(DictionaryEntries::value)
.flatMap(Arrays::stream)
.map(FuzzerDictionary::escapeForDictionary);
}
Expand Down

0 comments on commit b121327

Please sign in to comment.