Skip to content

Commit cfa3f93

Browse files
committed
Use clones in property test assertions
Updated property-based tests in csrf/token.rs and oauth2/tokens.rs to use .clone() on values in prop_assert_eq! and prop_assert_ne! macros. This ensures that the tests do not move values, improving clarity and preventing potential ownership issues.
1 parent 7ca7a20 commit cfa3f93

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

crates/rustapi-extras/src/csrf/token.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ mod property_tests {
108108
let token_str = token1.as_str();
109109
let token2 = CsrfToken::new(token_str.to_string());
110110

111-
prop_assert_eq!(token1, token2);
111+
prop_assert_eq!(token1.clone(), token2.clone());
112112
prop_assert_eq!(token1.as_str(), token2.as_str());
113113
}
114114

@@ -120,7 +120,7 @@ mod property_tests {
120120

121121
// With cryptographically secure random generation,
122122
// two tokens should never be equal
123-
prop_assert_ne!(token1, token2);
123+
prop_assert_ne!(token1.clone(), token2.clone());
124124
prop_assert_ne!(token1.as_str(), token2.as_str());
125125
}
126126

crates/rustapi-extras/src/oauth2/tokens.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ mod property_tests {
403403
let header = response.authorization_header();
404404

405405
let expected = format!("{} {}", token_type, access_token);
406-
prop_assert_eq!(header, expected);
406+
prop_assert_eq!(header.clone(), expected);
407407

408408
// Header should start with token type
409409
prop_assert!(header.starts_with(&token_type));
@@ -471,7 +471,7 @@ mod property_tests {
471471
let state2 = CsrfState::generate();
472472

473473
// Each state should be unique
474-
prop_assert_ne!(state1, state2);
474+
prop_assert_ne!(state1.clone(), state2.clone());
475475
prop_assert_ne!(state1.as_str(), state2.as_str());
476476
}
477477

@@ -498,7 +498,7 @@ mod property_tests {
498498
let state1 = CsrfState::new(state_str.clone());
499499
let state2 = CsrfState::new(state1.as_str().to_string());
500500

501-
prop_assert_eq!(state1, state2);
501+
prop_assert_eq!(state1.clone(), state2.clone());
502502
prop_assert_eq!(state1.as_str(), state2.as_str());
503503
}
504504

0 commit comments

Comments
 (0)