Skip to content

Commit fe00e5a

Browse files
committed
test fmt::Display and fmt::Debug for RescaleError
1 parent 7014d13 commit fe00e5a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/errors/rescale.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,31 @@ impl<const N: usize, const M: usize> fmt::Display for RescaleError<N, M> {
3131
)
3232
}
3333
}
34+
35+
#[cfg(all(test, feature = "alloc"))]
36+
mod tests {
37+
use super::*;
38+
39+
use alloc::format;
40+
use alloc::string::ToString;
41+
use pretty_assertions::assert_eq;
42+
43+
#[test]
44+
fn test_rescale_error_display() {
45+
assert_eq!(
46+
RescaleError::<6, 4>::new(5).to_string(),
47+
concat!(
48+
"failed to rescale the map of size `5` and capacity `6`,",
49+
" because the new map can hold at most `4` elements",
50+
)
51+
);
52+
}
53+
54+
#[test]
55+
fn test_rescale_error_debug() {
56+
assert_eq!(
57+
format!("{:?}", RescaleError::<6, 4>::new(5)),
58+
stringify!(RescaleError)
59+
);
60+
}
61+
}

0 commit comments

Comments
 (0)