Skip to content

Commit 0f1aa8a

Browse files
committed
Improve the testing of combinations.
1 parent 6b74327 commit 0f1aa8a

1 file changed

Lines changed: 23 additions & 10 deletions

File tree

src/utils.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,22 @@ mod tests {
258258
use super::*;
259259

260260
#[test]
261-
fn equals() {
262-
assert!(Combinations::new(vec![2, 2, 2], 2).next().unwrap() == vec![2, 2])
261+
fn combinations_next_works_as_expected() {
262+
assert_eq!(
263+
Combinations::new(vec![2, 2, 2], 2).next().unwrap() ,
264+
vec![2, 2],
265+
"next should return the next combination"
266+
)
263267
}
264268

265269
#[test]
266-
fn t_123() {
267-
assert!(
268-
dbg!(Combinations::new(vec![1, 2, 3], 2)
270+
fn combinations_generate_works_as_expected() {
271+
assert_eq!(
272+
Combinations::new(vec![1, 2, 3], 2)
269273
.take(10)
270-
.collect::<Vec<_>>())
271-
== vec![vec![1, 2], vec![1, 3], vec![2, 3]]
274+
.collect::<Vec<_>>(),
275+
vec![vec![1, 2], vec![1, 3], vec![2, 3]],
276+
"take should return the correct combinations"
272277
)
273278
}
274279

@@ -284,11 +289,15 @@ mod tests {
284289
vec![2, 2, 4],
285290
vec![2, 3, 4],
286291
];
287-
assert!(actual == expected)
292+
assert_eq!(
293+
actual,
294+
expected,
295+
"Complex combinations should work as expected"
296+
)
288297
}
289298

290299
#[test]
291-
fn test_str() {
300+
fn test_combinations_with_strings() {
292301
let actual: Vec<_> = Combinations::new(vec!["1", "2", "2", "3", "4"], 3).collect();
293302
let expected = vec![
294303
vec!["1", "2", "2"],
@@ -299,6 +308,10 @@ mod tests {
299308
vec!["2", "2", "4"],
300309
vec!["2", "3", "4"],
301310
];
302-
assert!(actual == expected)
311+
assert_eq!(
312+
actual,
313+
expected,
314+
"combinations of strings should work as expected"
315+
)
303316
}
304317
}

0 commit comments

Comments
 (0)