diff --git a/Makefile b/Makefile index 8ac7e39..517a79e 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,10 @@ # Run all cargo checks and tests. -build: +lint: cargo fmt - cargo clippy + cargo clippy --all-targets --all-features -- -D warnings RUSTDOCFLAGS="-D missing_docs" cargo doc --document-private-items --no-deps + +test: cargo test --release benchmark-small: diff --git a/src/data/course_generator/literacy.rs b/src/data/course_generator/literacy.rs index 447fb4a..0de8ac7 100644 --- a/src/data/course_generator/literacy.rs +++ b/src/data/course_generator/literacy.rs @@ -642,7 +642,7 @@ mod test { // Manifest with an empty name. let course_manifest = CourseManifest { id: "course_id".into(), - name: "".into(), + name: String::new(), dependencies: vec![], encompassed: vec![], superseded: vec![], diff --git a/src/exercise_scorer.rs b/src/exercise_scorer.rs index 7e1d365..6568c15 100644 --- a/src/exercise_scorer.rs +++ b/src/exercise_scorer.rs @@ -592,7 +592,7 @@ mod test { }, ]; let medium_difficulty = PowerLawScorer::estimate_difficulty(&medium_trials); - assert!(medium_difficulty >= 4.0 && medium_difficulty < 7.0); + assert!((4.0..7.0).contains(&medium_difficulty)); // A mixed history should yield an intermediate difficulty from aggregate failures. let mixed_trials = vec![ @@ -670,7 +670,7 @@ mod test { /// Verifies scoring an exercise with an invalid timestamp still returns a sane score. #[test] - fn invalid_timestamp() -> Result<()> { + fn invalid_timestamp() { let score = score_helper( ExerciseType::Declarative, &[ExerciseTrial { @@ -684,12 +684,11 @@ mod test { assert!(score.value >= 0.0 && score.value <= 5.0); assert!(score.value < 1.0); // Low due to long time elapsed assert!((0.0..=1.0).contains(&score.urgency)); - Ok(()) } /// Verifies extreme timestamp gaps do not overflow elapsed-time calculations. #[test] - fn extreme_timestamp_gap_does_not_overflow() -> Result<()> { + fn extreme_timestamp_gap_does_not_overflow() { let score = score_helper( ExerciseType::Declarative, &[ @@ -709,7 +708,6 @@ mod test { ); assert!(score.value >= 0.0 && score.value <= 5.0); assert!((0.0..=1.0).contains(&score.urgency)); - Ok(()) } /// Verifies stability computation evolves correctly through reviews. @@ -961,7 +959,7 @@ mod test { let failure_gain = PowerLawScorer::compute_spacing_gain(&ExerciseType::Declarative, 10.0, stability, -0.5); - assert!(short_interval_gain >= 1.0 && short_interval_gain <= 1.0 + SPACING_EFFECT_WEIGHT); + assert!((1.0..=1.0 + SPACING_EFFECT_WEIGHT).contains(&short_interval_gain)); assert!(long_interval_gain > short_interval_gain); assert_eq!(neutral_gain, 1.0); assert_eq!(failure_gain, 1.0); @@ -1143,7 +1141,7 @@ mod test { /// Verifies that a recent bad performance results in a very low score. #[test] - fn score_bad_recent() -> Result<()> { + fn score_bad_recent() { let trials = vec![ ExerciseTrial { score: 1.0, @@ -1173,12 +1171,11 @@ mod test { Utc::now().timestamp(), ); assert!(score.value < 2.0); - Ok(()) } /// Verifies score for mixed performance history. #[test] - fn score_mixed_performance() -> Result<()> { + fn score_mixed_performance() { let trials = vec![ ExerciseTrial { score: 3.0, @@ -1238,7 +1235,6 @@ mod test { Utc::now().timestamp(), ); assert!(score.value > 1.0 && score.value < 4.0); - Ok(()) } /// Verifies that trials not sorted in descending order by timestamp return an error. @@ -1266,7 +1262,7 @@ mod test { /// Verifies that trials with old timestamp result in a low score. #[test] - fn score_old_timestamp() -> Result<()> { + fn score_old_timestamp() { let score = score_helper( ExerciseType::Declarative, &[ExerciseTrial { @@ -1278,12 +1274,11 @@ mod test { Utc::now().timestamp(), ); assert!(score.value < 3.0); - Ok(()) } /// Verifies that the score for multiple good trials is very close to the maximum score. #[test] - fn score_multiple_good() -> Result<()> { + fn score_multiple_good() { let trials = vec![ ExerciseTrial { score: 5.0, @@ -1333,12 +1328,11 @@ mod test { Utc::now().timestamp(), ); assert!(score.value > 4.0); - Ok(()) } /// Verifies that multiple bad trials result in a very low score. #[test] - fn score_multiple_bad() -> Result<()> { + fn score_multiple_bad() { let trials = vec![ ExerciseTrial { score: 1.0, @@ -1388,13 +1382,12 @@ mod test { Utc::now().timestamp(), ); assert!(score.value < 2.0); - Ok(()) } /// Verifies that many old and well-spaced trials with good scores return a score that is still /// good due to high stability. #[test] - fn score_old_good_trials() -> Result<()> { + fn score_old_good_trials() { let trials = vec![ ExerciseTrial { score: 5.0, @@ -1441,13 +1434,12 @@ mod test { Utc::now().timestamp(), ); assert!(score.value >= 3.5); - Ok(()) } /// Verifies that very old trials of an exercise with good scores return a high score due to /// strong stability. #[test] - fn score_very_good_old_trials() -> Result<()> { + fn score_very_good_old_trials() { let trials = vec![ ExerciseTrial { score: 5.0, @@ -1494,7 +1486,6 @@ mod test { Utc::now().timestamp(), ); assert!(score.value >= 3.5); - Ok(()) } /// Verifies that urgency increases as an otherwise identical review becomes older. @@ -1636,7 +1627,7 @@ mod test { /// Verifies that positive deltas increase the score beyond the score with no deltas provided. #[test] - fn score_with_positive_deltas() -> Result<()> { + fn score_with_positive_deltas() { let trials = vec![ ExerciseTrial { score: 3.0, @@ -1680,12 +1671,11 @@ mod test { Utc::now().timestamp(), ); assert!(delta_score.value > base_score.value); - Ok(()) } /// Verifies that negative deltas decrease the score below the score with no deltas provided. #[test] - fn score_with_negative_deltas() -> Result<()> { + fn score_with_negative_deltas() { let trials = vec![ ExerciseTrial { score: 3.0, @@ -1729,6 +1719,5 @@ mod test { Utc::now().timestamp(), ); assert!(delta_score.value < base_score.value); - Ok(()) } } diff --git a/src/practice_deltas.rs b/src/practice_deltas.rs index 78c10c9..aa62749 100644 --- a/src/practice_deltas.rs +++ b/src/practice_deltas.rs @@ -237,16 +237,12 @@ mod test { fn assert_deltas(expected: &[f32], actual: &[ExerciseDelta]) { let only_deltas: Vec = actual.iter().map(|t| t.delta).collect(); assert_eq!(expected, only_deltas); - let timestamp_sorted = actual - .iter() - .enumerate() - .map(|(i, _)| { - if i == 0 { - return true; - } - actual[i - 1].timestamp >= actual[i].timestamp - }) - .all(|b| b); + let timestamp_sorted = actual.iter().enumerate().all(|(i, _)| { + if i == 0 { + return true; + } + actual[i - 1].timestamp >= actual[i].timestamp + }); assert!(timestamp_sorted); } diff --git a/src/practice_rewards.rs b/src/practice_rewards.rs index 227f8ce..4a028c0 100644 --- a/src/practice_rewards.rs +++ b/src/practice_rewards.rs @@ -319,16 +319,12 @@ mod test { assert_eq!(expected_rewards, only_rewards); let only_weights: Vec = actual.iter().map(|t| t.weight).collect(); assert_eq!(expected_weights, only_weights); - let timestamps_sorted = actual - .iter() - .enumerate() - .map(|(i, _)| { - if i == 0 { - return true; - } - actual[i - 1].timestamp >= actual[i].timestamp - }) - .all(|b| b); + let timestamps_sorted = actual.iter().enumerate().all(|(i, _)| { + if i == 0 { + return true; + } + actual[i - 1].timestamp >= actual[i].timestamp + }); assert!(timestamps_sorted); } @@ -393,7 +389,7 @@ mod test { unit_id, value: i as f32, weight: 1.0, - timestamp: i as i64, + timestamp: i64::from(i), }])?; } diff --git a/src/practice_stats.rs b/src/practice_stats.rs index 9093a79..a05194e 100644 --- a/src/practice_stats.rs +++ b/src/practice_stats.rs @@ -262,16 +262,12 @@ mod test { fn assert_scores(expected: &[f32], actual: &[ExerciseTrial]) { let only_scores: Vec = actual.iter().map(|t| t.score).collect(); assert_eq!(expected, only_scores); - let timestamp_sorted = actual - .iter() - .enumerate() - .map(|(i, _)| { - if i == 0 { - return true; - } - actual[i - 1].timestamp >= actual[i].timestamp - }) - .all(|b| b); + let timestamp_sorted = actual.iter().enumerate().all(|(i, _)| { + if i == 0 { + return true; + } + actual[i - 1].timestamp >= actual[i].timestamp + }); assert!(timestamp_sorted); } diff --git a/src/scheduler.rs b/src/scheduler.rs index 34351da..08f6759 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -1212,12 +1212,12 @@ mod test { fn select( lesson_score: f32, num_candidates: usize, - options: PassingScoreOptions, + options: &PassingScoreOptions, ) -> Vec { let candidates = (0..num_candidates) .map(|idx| candidate(idx as u32, 0.0, 1.0)) .collect::>(); - DepthFirstScheduler::select_candidates(candidates, lesson_score, &options) + DepthFirstScheduler::select_candidates(candidates, lesson_score, options) } /// Returns a candidate with the given exercise and lesson IDs. @@ -1255,7 +1255,7 @@ mod test { let candidates = select( 2.0, 5, - PassingScoreOptions { + &PassingScoreOptions { min_score: 3.0, min_fraction: 0.2, min_avg_trials: 2.0, @@ -1271,7 +1271,7 @@ mod test { let candidates = select( 2.0, 5, - PassingScoreOptions { + &PassingScoreOptions { min_score: 3.0, min_fraction: 0.0, min_avg_trials: 2.0, @@ -1287,7 +1287,7 @@ mod test { let candidates = select( 3.0, 2, - PassingScoreOptions { + &PassingScoreOptions { min_score: 3.0, min_fraction: 0.2, min_avg_trials: 2.0, @@ -1303,7 +1303,7 @@ mod test { let candidates = select( 3.8, 10, - PassingScoreOptions { + &PassingScoreOptions { min_score: 3.0, min_fraction: 0.2, min_avg_trials: 2.0, @@ -1319,7 +1319,7 @@ mod test { let candidates = select( 3.01, 2, - PassingScoreOptions { + &PassingScoreOptions { min_score: 3.0, min_fraction: 0.0, min_avg_trials: 2.0, @@ -1334,7 +1334,7 @@ mod test { let candidates = select( 5.0, 11, - PassingScoreOptions { + &PassingScoreOptions { min_score: 3.0, min_fraction: 0.2, min_avg_trials: 2.0, diff --git a/src/scheduler/filter.rs b/src/scheduler/filter.rs index 139fc87..2d1d378 100644 --- a/src/scheduler/filter.rs +++ b/src/scheduler/filter.rs @@ -460,9 +460,9 @@ mod test { assert!(final_candidates.len() < batch_size); // Verify that remainders are not added when the batch is already full enough. - let mut final_candidates_full = (0..batch_size * 3 / 4 + 1) + let mut final_candidates_full = (0..=(batch_size * 3 / 4)) .map(|i| Candidate { - exercise_id: Ustr::from(&format!("exercise{}", i)), + exercise_id: Ustr::from(&format!("exercise{i}")), ..Default::default() }) .collect::>(); diff --git a/src/scheduler/relearn_pile.rs b/src/scheduler/relearn_pile.rs index a6a807d..ea95227 100644 --- a/src/scheduler/relearn_pile.rs +++ b/src/scheduler/relearn_pile.rs @@ -101,7 +101,7 @@ mod tests { ..SchedulerOptions::default() }); for i in 0..20 { - let exercise_id = Ustr::from(&format!("exercise_{}", i)); + let exercise_id = Ustr::from(&format!("exercise_{i}")); relearn_pile.update(exercise_id, &MasteryScore::One); } let pile = relearn_pile.select_exercises_helper(); diff --git a/src/scheduler/review_knocker.rs b/src/scheduler/review_knocker.rs index c46cfb7..66b3f3b 100644 --- a/src/scheduler/review_knocker.rs +++ b/src/scheduler/review_knocker.rs @@ -244,30 +244,28 @@ mod tests { let mut unit_graph = InMemoryUnitGraph::default(); for course_index in 0..num_courses { // Add course and an encompassing relationship to the previous course. - let course_id = Ustr::from(&format!("course_{}", course_index)); + let course_id = Ustr::from(&format!("course_{course_index}")); unit_graph.add_course(course_id)?; if course_index > 0 { unit_graph.add_encompassed( course_id, - &vec![Ustr::from(&format!("course_{}", course_index - 1))], - &vec![], + &[Ustr::from(&format!("course_{}", course_index - 1))], + &[], )?; } // Add lessons and dependencies on the previous lesson. for lesson_index in 0..num_lessons_per_course { - let lesson_id = - Ustr::from(&format!("course_{}_lesson_{}", course_index, lesson_index)); + let lesson_id = Ustr::from(&format!("course_{course_index}_lesson_{lesson_index}")); unit_graph.add_lesson(lesson_id, course_id)?; if lesson_index > 0 { unit_graph.add_encompassed( lesson_id, - &vec![Ustr::from(&format!( - "course_{}_lesson_{}", - course_index, + &[Ustr::from(&format!( + "course_{course_index}_lesson_{}", lesson_index - 1 ))], - &vec![], + &[], )?; } } @@ -277,13 +275,10 @@ mod tests { let initial_batch = (0..num_courses) .flat_map(|course_index| { (0..num_lessons_per_course).map(move |lesson_index| Candidate { - exercise_id: Ustr::from(&format!("ex{}_{}", course_index, lesson_index)), + exercise_id: Ustr::from(&format!("ex{course_index}_{lesson_index}")), exercise_score: 4.5, - lesson_id: Ustr::from(&format!( - "course_{}_lesson_{}", - course_index, lesson_index - )), - course_id: Ustr::from(&format!("course_{}", course_index)), + lesson_id: Ustr::from(&format!("course_{course_index}_lesson_{lesson_index}")), + course_id: Ustr::from(&format!("course_{course_index}")), ..Default::default() }) }) @@ -295,7 +290,7 @@ mod tests { ReviewKnocker::compute_encompassing_map(&initial_batch, &unit_graph, false); for course_id in 0..5 { for lesson_id in 0..num_lessons_per_course { - let exercise_id = Ustr::from(&format!("ex{}_{}", course_id, lesson_id)); + let exercise_id = Ustr::from(&format!("ex{course_id}_{lesson_id}")); let weight = weight_map.get(&exercise_id).copied().unwrap_or(0.0); assert!(weight >= VERY_HIGHLY_WEIGHT,); } @@ -317,7 +312,7 @@ mod tests { ReviewKnocker::compute_encompassing_map(&initial_batch, &unit_graph, true); for course_id in (num_courses - 5)..num_courses { for lesson_id in 0..num_lessons_per_course { - let exercise_id = Ustr::from(&format!("ex{}_{}", course_id, lesson_id)); + let exercise_id = Ustr::from(&format!("ex{course_id}_{lesson_id}")); let weight = reverse_map.get(&exercise_id).copied().unwrap_or(0.0); assert!(weight >= VERY_HIGHLY_WEIGHT,); } @@ -341,12 +336,11 @@ mod tests { let num_lessons_per_course = 3; let mut unit_graph = InMemoryUnitGraph::default(); for course_index in 0..num_courses { - let course_id = Ustr::from(&format!("course_{}", course_index)); + let course_id = Ustr::from(&format!("course_{course_index}")); unit_graph.add_course(course_id)?; for lesson_index in 0..num_lessons_per_course { - let lesson_id = - Ustr::from(&format!("course_{}_lesson_{}", course_index, lesson_index)); + let lesson_id = Ustr::from(&format!("course_{course_index}_lesson_{lesson_index}")); unit_graph.add_lesson(lesson_id, course_id)?; } } @@ -355,13 +349,10 @@ mod tests { let initial_batch = (0..num_courses) .flat_map(|course_index| { (0..num_lessons_per_course).map(move |lesson_index| Candidate { - exercise_id: Ustr::from(&format!("ex{}_{}", course_index, lesson_index)), + exercise_id: Ustr::from(&format!("ex{course_index}_{lesson_index}")), exercise_score: 4.5, - lesson_id: Ustr::from(&format!( - "course_{}_lesson_{}", - course_index, lesson_index - )), - course_id: Ustr::from(&format!("course_{}", course_index)), + lesson_id: Ustr::from(&format!("course_{course_index}_lesson_{lesson_index}")), + course_id: Ustr::from(&format!("course_{course_index}")), ..Default::default() }) }) @@ -373,7 +364,7 @@ mod tests { ReviewKnocker::compute_encompassing_map(&initial_batch, &unit_graph, false); for course_index in 0..num_courses { for lesson_index in 0..num_lessons_per_course { - let exercise_id = Ustr::from(&format!("ex{}_{}", course_index, lesson_index)); + let exercise_id = Ustr::from(&format!("ex{course_index}_{lesson_index}")); let weight = weight_map.get(&exercise_id).copied().unwrap_or(0.0); assert_eq!(weight, 0.0); } @@ -384,7 +375,7 @@ mod tests { ReviewKnocker::compute_encompassing_map(&initial_batch, &unit_graph, true); for course_index in 0..num_courses { for lesson_index in 0..num_lessons_per_course { - let exercise_id = Ustr::from(&format!("ex{}_{}", course_index, lesson_index)); + let exercise_id = Ustr::from(&format!("ex{course_index}_{lesson_index}")); let weight = reverse_map.get(&exercise_id).copied().unwrap_or(0.0); assert_eq!(weight, 0.0); } diff --git a/src/scheduler/reward_propagator.rs b/src/scheduler/reward_propagator.rs index bbe7643..ca06f81 100644 --- a/src/scheduler/reward_propagator.rs +++ b/src/scheduler/reward_propagator.rs @@ -204,7 +204,7 @@ mod test { } /// Propagates a score of five through the graph and return the rewards as a map. - fn propagate_five_rewards(unit_graph: &dyn UnitGraph) -> Result> { + fn propagate_five_rewards(unit_graph: &dyn UnitGraph) -> UstrMap { let rewards = RewardPropagator::propagate_rewards_helper( unit_graph, Ustr::from("0::0"), @@ -212,10 +212,10 @@ mod test { &MasteryScore::Five, 0, ); - Ok(rewards + rewards .into_iter() .map(|reward| (reward.unit_id, reward)) - .collect()) + .collect() } /// Verifies the initial reward for each score. @@ -253,7 +253,7 @@ mod test { #[test] fn strongest_path_wins() -> Result<()> { let graph = build_path_graph(&[(Ustr::from("0::1"), 1.0), (Ustr::from("0::2"), 0.5)])?; - let reward_map = propagate_five_rewards(&graph)?; + let reward_map = propagate_five_rewards(&graph); let reward = reward_map.get(&Ustr::from("0::3")).unwrap(); assert!((reward.value - 0.72).abs() < f32::EPSILON); assert!((reward.weight - 0.8).abs() < f32::EPSILON); @@ -267,11 +267,11 @@ mod test { build_path_graph(&[(Ustr::from("0::1"), 1.0), (Ustr::from("0::2"), 0.5)])?; let second_order = build_path_graph(&[(Ustr::from("0::2"), 0.5), (Ustr::from("0::1"), 1.0)])?; - let first_reward = propagate_five_rewards(&first_order)? + let first_reward = propagate_five_rewards(&first_order) .get(&Ustr::from("0::3")) .cloned() .unwrap(); - let second_reward = propagate_five_rewards(&second_order)? + let second_reward = propagate_five_rewards(&second_order) .get(&Ustr::from("0::3")) .cloned() .unwrap(); @@ -291,7 +291,7 @@ mod test { graph.add_encompassed(Ustr::from("0::0"), &[], &[(Ustr::from("0::1"), 0.8)])?; graph.add_encompassed(Ustr::from("0::1"), &[], &[(Ustr::from("0::2"), 0.8)])?; - let reward_map = propagate_five_rewards(&graph)?; + let reward_map = propagate_five_rewards(&graph); let first_hop = reward_map.get(&Ustr::from("0::1")).unwrap(); assert!((first_hop.value - 0.64).abs() < f32::EPSILON); assert!((first_hop.weight - 0.8).abs() < f32::EPSILON); @@ -311,7 +311,7 @@ mod test { graph.add_lesson(Ustr::from("0::1"), Ustr::from("0"))?; graph.add_encompassed(Ustr::from("0::0"), &[], &[(Ustr::from("0::1"), 0.1)])?; - let reward_map = propagate_five_rewards(&graph)?; + let reward_map = propagate_five_rewards(&graph); assert!(reward_map.is_empty()); Ok(()) } @@ -327,7 +327,7 @@ mod test { graph.add_encompassed(Ustr::from("0::0"), &[], &[(Ustr::from("0::1"), 1.0)])?; graph.add_encompassed(Ustr::from("0::1"), &[], &[(Ustr::from("0::2"), 0.1)])?; - let reward_map = propagate_five_rewards(&graph)?; + let reward_map = propagate_five_rewards(&graph); assert!(reward_map.contains_key(&Ustr::from("0::1"))); assert!(!reward_map.contains_key(&Ustr::from("0::2"))); Ok(()) diff --git a/tests/basic_tests.rs b/tests/basic_tests.rs index 9eddda0..99b88d2 100644 --- a/tests/basic_tests.rs +++ b/tests/basic_tests.rs @@ -595,10 +595,7 @@ fn schedule_exercises_in_review_list() -> Result<()> { let exercise_ids = all_test_exercises(&LIBRARY); for exercise_id in exercise_ids { let exercise_ustr = exercise_id.to_ustr(); - if review_exercises - .iter() - .any(|review_exercise_id| *review_exercise_id == exercise_id) - { + if review_exercises.contains(&exercise_id) { assert!( simulation.answer_history.contains_key(&exercise_ustr), "exercise {:?} should have been scheduled", @@ -1164,7 +1161,7 @@ fn serialized_course_library() -> Result<()> { // Open a new trane instance using the serialized library. let trane = Trane::new_local_from_serialized(temp_dir.path(), serialized_data)?; - assert!(trane.get_all_exercise_ids(None).len() > 0); + assert!(!trane.get_all_exercise_ids(None).is_empty()); Ok(()) } diff --git a/tests/blacklist_tests.rs b/tests/blacklist_tests.rs index 830a5e8..7df0ed2 100644 --- a/tests/blacklist_tests.rs +++ b/tests/blacklist_tests.rs @@ -285,10 +285,7 @@ fn avoid_scheduling_exercises_in_blacklist() -> Result<()> { let exercise_ids = all_test_exercises(&LIBRARY); for exercise_id in exercise_ids { let exercise_ustr = exercise_id.to_ustr(); - if !exercise_blacklist - .iter() - .any(|blacklisted_id| *blacklisted_id == exercise_id) - { + if !exercise_blacklist.contains(&exercise_id) { assert!( simulation.answer_history.contains_key(&exercise_ustr), "exercise {:?} should have been scheduled", @@ -343,10 +340,7 @@ fn invalidate_cache_on_blacklist_update() -> Result<()> { // Every blacklisted exercise should not have been scheduled. let exercise_ids = all_test_exercises(&LIBRARY); for exercise_id in &exercise_ids { - if exercise_blacklist - .iter() - .any(|blacklisted_id| *blacklisted_id == *exercise_id) - { + if exercise_blacklist.contains(exercise_id) { let exercise_ustr = exercise_id.to_ustr(); assert!( !simulation.answer_history.contains_key(&exercise_ustr), @@ -370,11 +364,11 @@ fn invalidate_cache_on_blacklist_update() -> Result<()> { trane.remove_from_blacklist(exercise_id.to_ustr())?; } let mut simulation = TraneSimulation::new(500, Box::new(|_| Some(MasteryScore::One))); - simulation.run_simulation(&mut trane, &vec![], &None)?; + simulation.run_simulation(&mut trane, &Vec::new(), &None)?; // Trane should not schedule any lesson or course depending on the lesson with ID `TestId(0, // Some(0), None)`. - let unscheduled_lessons = vec![ + let unscheduled_lessons = [ TestId(0, Some(1), None), TestId(1, Some(0), None), TestId(1, Some(1), None), diff --git a/tests/knowledge_base_tests.rs b/tests/knowledge_base_tests.rs index 6df0d3e..ed78a9c 100644 --- a/tests/knowledge_base_tests.rs +++ b/tests/knowledge_base_tests.rs @@ -188,7 +188,7 @@ fn all_exercises_visited() -> Result<()> { // Initialize the Trane library. let temp_dir = TempDir::new()?; let mut trane = - init_knowledge_base_simulation(temp_dir.path(), &vec![course1_builder, course2_builder])?; + init_knowledge_base_simulation(temp_dir.path(), &[course1_builder, course2_builder])?; // Run the simulation. let exercise_ids = trane.get_all_exercise_ids(None); diff --git a/tests/metadata_tests.rs b/tests/metadata_tests.rs index fb0c5ed..2f2d37c 100644 --- a/tests/metadata_tests.rs +++ b/tests/metadata_tests.rs @@ -831,7 +831,10 @@ fn scheduler_bridges_filtered_dependency_chain() -> Result<()> { let d_exercise = TestId(3, Some(0), Some(0)).to_ustr(); let passing_score = trane.get_scheduler_options().passing_score.min_score; assert!( - trane.get_exercise_ids(a_lesson).unwrap_or_default().len() > 0, + !trane + .get_exercise_ids(a_lesson) + .unwrap_or_default() + .is_empty(), "lesson {:?} should contain at least one exercise", a_lesson );