Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ itoa = "1"

[dev-dependencies]
quickcheck = "1"
rand = "0.8.0"
rand = "0.9.1"
serde = "1.0"
serde_json = "1.0"
doc-comment = "0.3"
21 changes: 11 additions & 10 deletions tests/header_map_fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ use http::header::*;
use http::*;

use quickcheck::{Arbitrary, Gen, QuickCheck, TestResult};
use rand::prelude::IndexedRandom;
use rand::rngs::StdRng;
use rand::seq::SliceRandom;
// use rand::seq::SliceRandom;
Comment thread
seanmonstar marked this conversation as resolved.
Outdated
use rand::{Rng, SeedableRng};

use std::collections::HashMap;
Expand Down Expand Up @@ -76,12 +77,12 @@ impl Fuzz {

let mut steps = vec![];
let mut expect = AltMap::default();
let num = rng.gen_range(5..500);
let num = rng.random_range(5..500);

let weight = Weight {
insert: rng.gen_range(1..10),
remove: rng.gen_range(1..10),
append: rng.gen_range(1..10),
insert: rng.random_range(1..10),
remove: rng.random_range(1..10),
append: rng.random_range(1..10),
};

while steps.len() < num {
Expand Down Expand Up @@ -112,7 +113,7 @@ impl Fuzz {

impl Arbitrary for Fuzz {
fn arbitrary(_: &mut Gen) -> Self {
Self::new(rand::thread_rng().gen())
Self::new(rand::rng().random())
}
}

Expand All @@ -130,7 +131,7 @@ impl AltMap {
fn gen_action(&mut self, weight: &Weight, rng: &mut StdRng) -> Action {
let sum = weight.insert + weight.remove + weight.append;

let mut num = rng.gen_range(0..sum);
let mut num = rng.random_range(0..sum);

if num < weight.insert {
return self.gen_insert(rng);
Expand Down Expand Up @@ -180,7 +181,7 @@ impl AltMap {

/// Negative numbers weigh finding an existing header higher
fn gen_name(&self, weight: i32, rng: &mut StdRng) -> HeaderName {
let mut existing = rng.gen_ratio(1, weight.abs() as u32);
let mut existing = rng.random_ratio(1, weight.abs() as u32);

if weight < 0 {
existing = !existing;
Expand All @@ -202,7 +203,7 @@ impl AltMap {
if self.map.is_empty() {
None
} else {
let n = rng.gen_range(0..self.map.len());
let n = rng.random_range(0..self.map.len());
self.map.keys().nth(n).map(Clone::clone)
}
}
Expand Down Expand Up @@ -337,7 +338,7 @@ fn gen_header_name(g: &mut StdRng) -> HeaderName {
header::X_XSS_PROTECTION,
];

if g.gen_ratio(1, 2) {
if g.random_ratio(1, 2) {
STANDARD_HEADERS.choose(g).unwrap().clone()
} else {
let value = gen_string(g, 1, 25);
Expand Down
Loading