summaryrefslogtreecommitdiff
path: root/src/mutex
diff options
context:
space:
mode:
authorBotahamec <botahamec@outlook.com>2025-01-12 15:04:01 -0500
committerBotahamec <botahamec@outlook.com>2025-01-12 15:04:01 -0500
commit280a61ad7b74019c7aad8b7306a0dd7cfb11359c (patch)
tree40d97d4e183c1bc551194944876b099d875f361d /src/mutex
parentbf95904b3532a9175a7bfa14a3f216abbd15ee98 (diff)
More unit tests
Diffstat (limited to 'src/mutex')
-rw-r--r--src/mutex/guard.rs8
-rw-r--r--src/mutex/mutex.rs1
2 files changed, 9 insertions, 0 deletions
diff --git a/src/mutex/guard.rs b/src/mutex/guard.rs
index 0d35cf4..f7a01a4 100644
--- a/src/mutex/guard.rs
+++ b/src/mutex/guard.rs
@@ -33,12 +33,14 @@ impl<T: Ord + ?Sized, R: RawMutex> Ord for MutexRef<'_, T, R> {
}
}
+#[mutants::skip] // hashing involves RNG and is hard to test
impl<T: Hash + ?Sized, R: RawMutex> Hash for MutexRef<'_, T, R> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.deref().hash(state)
}
}
+#[mutants::skip]
impl<T: Debug + ?Sized, R: RawMutex> Debug for MutexRef<'_, T, R> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Debug::fmt(&**self, f)
@@ -103,14 +105,17 @@ impl<'a, T: ?Sized, R: RawMutex> MutexRef<'a, T, R> {
// it's kinda annoying to re-implement some of this stuff on guards
// there's nothing i can do about that
+#[mutants::skip] // it's hard to get two guards safely
impl<T: PartialEq + ?Sized, R: RawMutex, Key: Keyable> PartialEq for MutexGuard<'_, '_, T, Key, R> {
fn eq(&self, other: &Self) -> bool {
self.deref().eq(&**other)
}
}
+#[mutants::skip] // it's hard to get two guards safely
impl<T: Eq + ?Sized, R: RawMutex, Key: Keyable> Eq for MutexGuard<'_, '_, T, Key, R> {}
+#[mutants::skip] // it's hard to get two guards safely
impl<T: PartialOrd + ?Sized, R: RawMutex, Key: Keyable> PartialOrd
for MutexGuard<'_, '_, T, Key, R>
{
@@ -119,18 +124,21 @@ impl<T: PartialOrd + ?Sized, R: RawMutex, Key: Keyable> PartialOrd
}
}
+#[mutants::skip] // it's hard to get two guards safely
impl<T: Ord + ?Sized, R: RawMutex, Key: Keyable> Ord for MutexGuard<'_, '_, T, Key, R> {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.deref().cmp(&**other)
}
}
+#[mutants::skip] // hashing involves RNG and is hard to test
impl<T: Hash + ?Sized, R: RawMutex, Key: Keyable> Hash for MutexGuard<'_, '_, T, Key, R> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.deref().hash(state)
}
}
+#[mutants::skip]
impl<T: Debug + ?Sized, Key: Keyable, R: RawMutex> Debug for MutexGuard<'_, '_, T, Key, R> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Debug::fmt(&**self, f)
diff --git a/src/mutex/mutex.rs b/src/mutex/mutex.rs
index 7a3f75c..5b838a2 100644
--- a/src/mutex/mutex.rs
+++ b/src/mutex/mutex.rs
@@ -129,6 +129,7 @@ impl<T, R: RawMutex> Mutex<T, R> {
}
}
+#[mutants::skip]
impl<T: ?Sized + Debug, R: RawMutex> Debug for Mutex<T, R> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// safety: this is just a try lock, and the value is dropped