Skip to content

Commit 802b40c

Browse files
committed
tests: Resolve more clippy lints
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
1 parent 34b0b75 commit 802b40c

1 file changed

Lines changed: 56 additions & 61 deletions

File tree

src/tests.rs

Lines changed: 56 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,18 @@ fn get_segment_returns_none_on_zero_length_vec() {
6060

6161
#[test]
6262
fn position_correct_straight_line() {
63-
let mut segment = Vec::new();
64-
65-
segment.push(Pose3 {
66-
position: Vec3d(0.0f64, 0.0, 0.0),
67-
velocity: Vec3d(0.0, 0.0, 0.0),
68-
acceleration: Vec3d(0.0, 0.0, 0.0),
69-
});
70-
71-
segment.push(Pose3 {
72-
position: Vec3d(0.0f64, 1.0, 0.0),
73-
velocity: Vec3d(0.0, 0.0, 0.0),
74-
acceleration: Vec3d(0.0, 0.0, 0.0),
75-
});
63+
let segment = vec![
64+
Pose3 {
65+
position: Vec3d(0.0f64, 0.0, 0.0),
66+
velocity: Vec3d(0.0, 0.0, 0.0),
67+
acceleration: Vec3d(0.0, 0.0, 0.0),
68+
},
69+
Pose3 {
70+
position: Vec3d(0.0f64, 1.0, 0.0),
71+
velocity: Vec3d(0.0, 0.0, 0.0),
72+
acceleration: Vec3d(0.0, 0.0, 0.0),
73+
},
74+
];
7675

7776
assert_eq!(segment.position_at(0.0), Some(segment[0].position));
7877
assert_eq!(segment.position_at(0.5), Some(Vec3d(0.0, 0.5, 0.0)));
@@ -102,19 +101,18 @@ fn acceleration_length_zero() {
102101

103102
#[test]
104103
fn velocity_correct_straight_line_opp_starts() {
105-
let mut segment = Vec::new();
106-
107-
segment.push(Pose3 {
108-
position: Vec3d(0.0f64, 0.0, 0.0),
109-
velocity: Vec3d(0.0, 1.0, 0.0),
110-
acceleration: Vec3d(0.0, 0.0, 0.0),
111-
});
112-
113-
segment.push(Pose3 {
114-
position: Vec3d(0.0f64, 1.0, 0.0),
115-
velocity: Vec3d(0.0, 0.0, 0.0),
116-
acceleration: Vec3d(0.0, 0.0, 0.0),
117-
});
104+
let segment = vec![
105+
Pose3 {
106+
position: Vec3d(0.0f64, 0.0, 0.0),
107+
velocity: Vec3d(0.0, 1.0, 0.0),
108+
acceleration: Vec3d(0.0, 0.0, 0.0),
109+
},
110+
Pose3 {
111+
position: Vec3d(0.0f64, 1.0, 0.0),
112+
velocity: Vec3d(0.0, 0.0, 0.0),
113+
acceleration: Vec3d(0.0, 0.0, 0.0),
114+
},
115+
];
118116

119117
assert_eq!(segment.velocity_at(0.0), Some(segment[0].velocity));
120118
assert_eq!(segment.velocity_at(0.5), Some(Vec3d(0.0, 1.4375, 0.0)));
@@ -123,19 +121,18 @@ fn velocity_correct_straight_line_opp_starts() {
123121

124122
#[test]
125123
fn acceleration_correct_curve() {
126-
let mut segment = Vec::new();
127-
128-
segment.push(Pose3 {
129-
position: Vec3d(0.0f64, 0.0, 0.0),
130-
velocity: Vec3d(0.0, 1.0, 0.0),
131-
acceleration: Vec3d(1.0, 0.0, 0.0),
132-
});
133-
134-
segment.push(Pose3 {
135-
position: Vec3d(1.0f64, 1.0, 0.0),
136-
velocity: Vec3d(1.0, 0.0, 0.0),
137-
acceleration: Vec3d(0.0, -1.0, 0.0),
138-
});
124+
let segment = vec![
125+
Pose3 {
126+
position: Vec3d(0.0f64, 0.0, 0.0),
127+
velocity: Vec3d(0.0, 1.0, 0.0),
128+
acceleration: Vec3d(1.0, 0.0, 0.0),
129+
},
130+
Pose3 {
131+
position: Vec3d(1.0f64, 1.0, 0.0),
132+
velocity: Vec3d(1.0, 0.0, 0.0),
133+
acceleration: Vec3d(0.0, -1.0, 0.0),
134+
},
135+
];
139136

140137
assert_eq!(segment.acceleration_at(0.0), Some(segment[0].acceleration));
141138
assert_eq!(segment.acceleration_at(0.5), Some(Vec3d(1.25, -1.25, 0.0)));
@@ -144,28 +141,26 @@ fn acceleration_correct_curve() {
144141

145142
#[test]
146143
fn all_set_points_hit() {
147-
let mut segment = Vec::new();
148-
149-
// Start at origin, moving north at 1.0 u/s
150-
segment.push(Pose3 {
151-
position: Vec3d(0.0f64, 0.0, 0.0),
152-
velocity: Vec3d(0.0, 1.0, 0.0),
153-
acceleration: Vec3d(0.0, 0.0, 0.0),
154-
});
155-
156-
// Stop at (0,1,0)
157-
segment.push(Pose3 {
158-
position: Vec3d(0.0f64, 1.0, 0.0),
159-
velocity: Vec3d(0.0, 0.0, 0.0),
160-
acceleration: Vec3d(0.0, 0.0, 0.0),
161-
});
162-
163-
// Accelerate through (0,2,0), moving north at 1.0 u/s
164-
segment.push(Pose3 {
165-
position: Vec3d(0.0f64, 2.0, 0.0),
166-
velocity: Vec3d(0.0, 1.0, 0.0),
167-
acceleration: Vec3d(0.0, 0.0, 0.0),
168-
});
144+
let segment = vec![
145+
// Start at origin, moving north at 1.0 u/s
146+
Pose3 {
147+
position: Vec3d(0.0f64, 0.0, 0.0),
148+
velocity: Vec3d(0.0, 1.0, 0.0),
149+
acceleration: Vec3d(0.0, 0.0, 0.0),
150+
},
151+
// Stop at (0,1,0)
152+
Pose3 {
153+
position: Vec3d(0.0f64, 1.0, 0.0),
154+
velocity: Vec3d(0.0, 0.0, 0.0),
155+
acceleration: Vec3d(0.0, 0.0, 0.0),
156+
},
157+
// Accelerate through (0,2,0), moving north at 1.0 u/s
158+
Pose3 {
159+
position: Vec3d(0.0f64, 2.0, 0.0),
160+
velocity: Vec3d(0.0, 1.0, 0.0),
161+
acceleration: Vec3d(0.0, 0.0, 0.0),
162+
},
163+
];
169164

170165
assert_eq!(segment.position_at(0.0), Some(segment[0].position));
171166
assert_eq!(segment.velocity_at(0.0), Some(segment[0].velocity));

0 commit comments

Comments
 (0)