Skip to content

Commit ffdefd4

Browse files
committed
random usage is fixed in tests
1 parent 4e88c87 commit ffdefd4

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ default = []
3030
validation = []
3131

3232
[[bench]]
33-
name = "doubly_shuffling_around"
33+
name = "doubly_mutation_ends"
3434
harness = false

tests/doubly.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ const ACTIONS: [Actions; 10] = [
3737
const GROW_ACTIONS: [Actions; 3] = [Actions::PushBack, Actions::PushFront, Actions::Insert];
3838

3939
fn val(r: &mut R) -> String {
40-
r.gen_range(0..10000).to_string()
40+
r.random_range(0..10000).to_string()
4141
}
4242

4343
impl Actions {
4444
fn pick_grow(r: &mut R) -> Self {
45-
GROW_ACTIONS[r.gen_range(0..GROW_ACTIONS.len())]
45+
GROW_ACTIONS[r.random_range(0..GROW_ACTIONS.len())]
4646
}
4747

4848
fn pick(r: &mut R) -> Self {
49-
ACTIONS[r.gen_range(0..ACTIONS.len())]
49+
ACTIONS[r.random_range(0..ACTIONS.len())]
5050
}
5151

5252
fn apply<M>(self, r: &mut R, list: &mut List<Doubly<String>, M>)
@@ -86,14 +86,14 @@ impl Actions {
8686
Insert => {
8787
let pos = match list.len() {
8888
0 => 0,
89-
_ => r.gen_range(0..=list.len()),
89+
_ => r.random_range(0..=list.len()),
9090
};
9191
list.insert_at(pos, val(r));
9292
}
9393
Remove => {
9494
let pos = match list.len() {
9595
0 => 0,
96-
_ => r.gen_range(0..list.len()),
96+
_ => r.random_range(0..list.len()),
9797
};
9898
list.remove_at(pos);
9999
}

tests/list_swap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ fn list_swap() {
1919
let mut control: Vec<_> = list.iter().cloned().collect();
2020

2121
for _ in 0..100 {
22-
let a = r.gen_range(0..list.len());
23-
let b = r.gen_range(0..list.len());
22+
let a = r.random_range(0..list.len());
23+
let b = r.random_range(0..list.len());
2424

2525
list.swap(&idx[a], &idx[b]);
2626

tests/singly.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ const ACTIONS: [Actions; 6] = [
2929
const GROW_ACTIONS: [Actions; 2] = [Actions::PushFront, Actions::Insert];
3030

3131
fn val(r: &mut R) -> String {
32-
r.gen_range(0..10000).to_string()
32+
r.random_range(0..10000).to_string()
3333
}
3434

3535
impl Actions {
3636
fn pick_grow(r: &mut R) -> Self {
37-
GROW_ACTIONS[r.gen_range(0..GROW_ACTIONS.len())]
37+
GROW_ACTIONS[r.random_range(0..GROW_ACTIONS.len())]
3838
}
3939

4040
fn pick(r: &mut R) -> Self {
41-
ACTIONS[r.gen_range(0..ACTIONS.len())]
41+
ACTIONS[r.random_range(0..ACTIONS.len())]
4242
}
4343

4444
fn apply<M>(self, r: &mut R, list: &mut List<Singly<String>, M>)
@@ -64,14 +64,14 @@ impl Actions {
6464
Insert => {
6565
let pos = match list.len() {
6666
0 => 0,
67-
_ => r.gen_range(0..=list.len()),
67+
_ => r.random_range(0..=list.len()),
6868
};
6969
list.insert_at(pos, val(r));
7070
}
7171
Remove => {
7272
let pos = match list.len() {
7373
0 => 0,
74-
_ => r.gen_range(0..list.len()),
74+
_ => r.random_range(0..list.len()),
7575
};
7676
list.remove_at(pos);
7777
}

tests/utilization.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ fn doubly() {
2929

3030
list.pop_front();
3131
#[cfg(target_pointer_width = "64")]
32-
assert_eq!(list.node_utilization().num_closed_nodes, 5);
32+
assert_eq!(list.node_utilization().num_closed_nodes, 6);
3333
#[cfg(target_pointer_width = "32")]
3434
assert_eq!(list.node_utilization().num_closed_nodes, 6);
3535

3636
list.pop_front();
3737
#[cfg(target_pointer_width = "64")]
38-
assert_eq!(list.node_utilization().num_closed_nodes, 6);
38+
assert_eq!(list.node_utilization().num_closed_nodes, 7);
3939
#[cfg(target_pointer_width = "32")]
40-
assert_eq!(list.node_utilization().num_closed_nodes, 0);
40+
assert_eq!(list.node_utilization().num_closed_nodes, 7);
4141

4242
list.pop_front();
4343
#[cfg(target_pointer_width = "64")]
4444
assert_eq!(list.node_utilization().num_closed_nodes, 0);
4545
#[cfg(target_pointer_width = "32")]
46-
assert_eq!(list.node_utilization().num_closed_nodes, 1);
46+
assert_eq!(list.node_utilization().num_closed_nodes, 0);
4747

4848
list.pop_back();
4949

@@ -78,12 +78,12 @@ fn singly() {
7878

7979
list.pop_front();
8080
#[cfg(target_pointer_width = "64")]
81-
assert_eq!(list.node_utilization().num_closed_nodes, 7);
81+
assert_eq!(list.node_utilization().num_closed_nodes, 1);
8282
#[cfg(target_pointer_width = "32")]
83-
assert_eq!(list.node_utilization().num_closed_nodes, 4);
83+
assert_eq!(list.node_utilization().num_closed_nodes, 1);
8484

8585
list.pop_front();
86-
assert_eq!(list.node_utilization().num_closed_nodes, 0);
86+
assert_eq!(list.node_utilization().num_closed_nodes, 2);
8787

8888
list.clear();
8989
assert_eq!(list.node_utilization().num_closed_nodes, 0);

0 commit comments

Comments
 (0)