chore(workspace): fix all clippy warnings in test code
Resolves 15 violations found by `cargo clippy --workspace --tests -D warnings`:
- Remove unused imports (Card, Rank) in cursor_plugin tests
- Replace absurd i32::MAX comparison with a meaningful >= 0 check
- Use range .contains() instead of manual >= && <= (manual_range_contains)
- Move impl FromRequestParts before test module in middleware.rs (items_after_test_module)
- Move _VEC3_REFERENCED const before test module in input_plugin.rs
- Convert runtime assert on constant to const { assert!(...) }
- Use .contains() instead of .iter().any() for slice membership
- Replace .get(...).is_none() with !.contains_key(...) in HashMap checks
- Collapse Default::default() + field assignment into struct literal initializers
across solitaire_sync, solitaire_data, and solitaire_engine test helpers
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -148,8 +148,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn add_xp_saturates_on_overflow() {
|
||||
let mut p = PlayerProgress::default();
|
||||
p.total_xp = u64::MAX - 5;
|
||||
let mut p = PlayerProgress { total_xp: u64::MAX - 5, ..Default::default() };
|
||||
p.add_xp(100);
|
||||
assert_eq!(p.total_xp, u64::MAX);
|
||||
}
|
||||
|
||||
@@ -207,8 +207,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn adjust_sfx_volume_clamps() {
|
||||
let mut s = Settings::default();
|
||||
s.sfx_volume = 0.5;
|
||||
let mut s = Settings { sfx_volume: 0.5, ..Default::default() };
|
||||
assert!((s.adjust_sfx_volume(0.3) - 0.8).abs() < 1e-6);
|
||||
assert!((s.adjust_sfx_volume(0.5) - 1.0).abs() < 1e-6);
|
||||
assert!((s.adjust_sfx_volume(-2.0) - 0.0).abs() < 1e-6);
|
||||
@@ -217,8 +216,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn adjust_music_volume_clamps() {
|
||||
let mut s = Settings::default();
|
||||
s.music_volume = 0.5;
|
||||
let mut s = Settings { music_volume: 0.5, ..Default::default() };
|
||||
assert!((s.adjust_music_volume(0.3) - 0.8).abs() < 1e-6);
|
||||
assert!((s.adjust_music_volume(0.5) - 1.0).abs() < 1e-6);
|
||||
assert!((s.adjust_music_volume(-2.0) - 0.0).abs() < 1e-6);
|
||||
@@ -241,14 +239,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn sanitized_clamps_music_volume() {
|
||||
let mut s = Settings::default();
|
||||
s.music_volume = 2.0;
|
||||
let s = s.sanitized();
|
||||
let s = Settings { music_volume: 2.0, ..Default::default() }.sanitized();
|
||||
assert_eq!(s.music_volume, 1.0);
|
||||
|
||||
let mut s2 = Settings::default();
|
||||
s2.music_volume = -0.5;
|
||||
let s2 = s2.sanitized();
|
||||
let s2 = Settings { music_volume: -0.5, ..Default::default() }.sanitized();
|
||||
assert_eq!(s2.music_volume, 0.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -173,8 +173,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn lifetime_score_saturates_at_u64_max() {
|
||||
let mut s = StatsSnapshot::default();
|
||||
s.lifetime_score = u64::MAX - 100;
|
||||
let mut s = StatsSnapshot { lifetime_score: u64::MAX - 100, ..Default::default() };
|
||||
s.update_on_win(200, 60, &DrawMode::DrawOne);
|
||||
assert_eq!(s.lifetime_score, u64::MAX, "lifetime_score must saturate, not overflow");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user