Skip to content

Commit

Permalink
test: Even more forking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Bluefinger committed Oct 18, 2023
1 parent 39516ab commit d9ba2d8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ where
#[cfg(test)]
mod tests {
use bevy::reflect::TypePath;
use bevy_prng::ChaCha8Rng;
use bevy_prng::{ChaCha8Rng, ChaCha12Rng};

use super::*;

Expand All @@ -249,6 +249,18 @@ mod tests {
);
}

#[test]
fn forking_as() {
let mut rng1 = EntropyComponent::<ChaCha12Rng>::default();

let rng2 = rng1.fork_as::<ChaCha8Rng>();

let rng1 = format!("{:?}", rng1);
let rng2 = format!("{:?}", rng2);

assert_ne!(&rng1, &rng2, "forked EntropyComponents should not match each other");
}

#[test]
fn forking_inner() {
let mut rng1 = EntropyComponent::<ChaCha8Rng>::default();
Expand Down
14 changes: 13 additions & 1 deletion src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ where
#[cfg(test)]
mod tests {
use bevy::reflect::TypePath;
use bevy_prng::ChaCha8Rng;
use bevy_prng::{ChaCha8Rng, ChaCha12Rng};

use super::*;

Expand Down Expand Up @@ -192,6 +192,18 @@ mod tests {
assert_ne!(source_val, forked_val);
}

#[test]
fn forking_as() {
let mut rng1 = GlobalEntropy::<ChaCha12Rng>::default();

let rng2 = rng1.fork_as::<ChaCha8Rng>();

let rng1 = format!("{:?}", rng1);
let rng2 = format!("{:?}", rng2);

assert_ne!(&rng1, &rng2, "GlobalEntropy should not match the forked component");
}

#[test]
fn forking_inner() {
let mut rng1 = GlobalEntropy::<ChaCha8Rng>::default();
Expand Down

0 comments on commit d9ba2d8

Please sign in to comment.