Skip to content

Commit 87618da

Browse files
committed
chore: update tests to use the sampler
After adding @DictionaryProvider to IntegralMutatorFactory, the selection of mutation functions now does an addition step that runs through weightedSampler, that selects whether to stay in the selection or do an additional step and select another.
1 parent 1536511 commit 87618da

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

src/test/java/com/code_intelligence/jazzer/mutation/mutator/aggregate/RecordMutatorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ void testSimpleTypesRecord() {
7979
// Mutate second component, in range operation, return 23
8080
1,
8181
2,
82+
0.1, // sampler: we stay in the second function: direct value in range
8283
23L)) {
8384
SimpleTypesRecord inited = mutator.init(prng);
8485
assertThat(inited).isNotNull();

src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/ArrayMutatorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ void testChangeSingleElement() {
215215
// mutation choice based on `IntegralMutatorFactory`
216216
// 2 == closedRange
217217
2,
218+
0.1, // sampler: we stay in the closed range mutation
218219
// value
219220
55L)) {
220221
arr = mutator.mutate(arr, prng);

src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/ListMutatorTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ void testChangeSingleElement() {
184184
// mutation choice based on `IntegralMutatorFactory`
185185
// 2 == closedRange
186186
2,
187+
0.1, // sampler: stay in closedRange mutation
187188
// value
188189
55L)) {
189190
list = mutator.mutate(list, prng);
@@ -208,10 +209,12 @@ void testChangeChunk() {
208209
5,
209210
// mutation: 0 == bitflip
210211
0,
212+
0.1, // sampler: stay in bitflip mutation
211213
// shift constant
212214
13,
213215
// and again
214216
0,
217+
0.1, // sampler: stay in bitflip mutation
215218
12)) {
216219
list = mutator.mutate(list, prng);
217220
}

src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/MapMutatorTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,12 @@ void mapMutateValues() {
149149
3,
150150
// uniform pick
151151
2,
152+
0.1, // sampler: stay in uniform pick
152153
// random integer
153154
41L,
154155
// uniform pick
155156
2,
157+
0.1, // sampler: stay in uniform pick
156158
// random integer
157159
51L)) {
158160
map = mutator.mutate(map, prng);
@@ -179,10 +181,12 @@ void mapMutateKeys() {
179181
3,
180182
// uniform pick
181183
2,
184+
0.1, // sampler: stay in uniform pick
182185
// integer
183186
7L,
184187
// uniform pick
185188
2,
189+
0.1, // sampler: stay in uniform pick
186190
// random integer
187191
8L)) {
188192
map = mutator.mutate(map, prng);

0 commit comments

Comments
 (0)