Skip to content

Commit 9751703

Browse files
mangelatsLuthaf
authored andcommitted
Prepare tests to add slice indexing methods' tests
1 parent f46e244 commit 9751703

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

tests/index.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,20 @@ mod particles;
22
use self::particles::{Particle, ParticleVec, ParticleRef};
33

44

5+
/// Helper function to assert that two iterators (one of SoA and another of AoS) are equal.
6+
fn eq_its<'a, I1, I2>(i1: I1, i2: I2)
7+
where
8+
I1: Iterator<Item = ParticleRef<'a>>,
9+
I2: Iterator<Item = &'a Particle>,
10+
{
11+
for (p1, p2) in i1.zip(i2) {
12+
assert_eq!(p1.name, &p2.name);
13+
assert_eq!(*p1.mass, p2.mass);
14+
}
15+
}
16+
517
#[test]
6-
fn test_usize() {
18+
fn test_vec_usize() {
719
let mut aos = Vec::new();
820
let mut soa = ParticleVec::new();
921

@@ -48,18 +60,8 @@ fn test_usize() {
4860
assert_eq!(soa.get(0).map(|p| *p.mass), Some(particle.mass));
4961
}
5062

51-
fn eq_its<'a, I1, I2>(i1: I1, i2: I2)
52-
where
53-
I1: Iterator<Item = ParticleRef<'a>>,
54-
I2: Iterator<Item = &'a Particle>,
55-
{
56-
for (p1, p2) in i1.zip(i2) {
57-
assert_eq!(*p1.mass, p2.mass);
58-
}
59-
}
60-
6163
#[test]
62-
fn test_ranges() {
64+
fn test_vec_ranges() {
6365
let mut particles = Vec::new();
6466
particles.push(Particle::new(String::from("Cl"), 1.0));
6567
particles.push(Particle::new(String::from("Na"), 2.0));

0 commit comments

Comments
 (0)