Skip to content

Commit 8bfc601

Browse files
committed
test Neg for Wrapping
1 parent 1ffb516 commit 8bfc601

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/ops/wrapping.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,7 @@ fn test_wrapping_traits() {
285285
assert_eq!(wrapping_add(255, 1), (Wrapping(255u8) + Wrapping(1u8)).0);
286286
assert_eq!(wrapping_sub(0, 1), (Wrapping(0u8) - Wrapping(1u8)).0);
287287
assert_eq!(wrapping_mul(255, 2), (Wrapping(255u8) * Wrapping(2u8)).0);
288-
// TODO: Test for Wrapping::Neg. Not possible yet since core::ops::Neg was
289-
// only added to core::num::Wrapping<_> in Rust 1.10.
288+
assert_eq!(wrapping_neg(255), (-Wrapping(255u8)).0);
290289
assert_eq!(wrapping_shl(255, 8), (Wrapping(255u8) << 8).0);
291290
assert_eq!(wrapping_shr(255, 8), (Wrapping(255u8) >> 8).0);
292291
}
@@ -309,8 +308,11 @@ fn wrapping_is_wrappingmul() {
309308
require_wrappingmul(&Wrapping(42));
310309
}
311310

312-
// TODO: Test for Wrapping::Neg. Not possible yet since core::ops::Neg was
313-
// only added to core::num::Wrapping<_> in Rust 1.10.
311+
#[test]
312+
fn wrapping_is_wrappingneg() {
313+
fn require_wrappingneg<T: WrappingNeg>(_: &T) {}
314+
require_wrappingneg(&Wrapping(42));
315+
}
314316

315317
#[test]
316318
fn wrapping_is_wrappingshl() {

src/sign.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,8 @@ fn unsigned_wrapping_is_unsigned() {
209209
require_unsigned(&Wrapping(42_u32));
210210
}
211211

212-
// Commenting this out since it doesn't compile on Rust 1.8,
213-
// because on this version Wrapping doesn't implement Neg and therefore can't
214-
// implement Signed.
215-
// #[test]
216-
// fn signed_wrapping_is_signed() {
217-
// fn require_signed<T: Signed>(_: &T) {}
218-
// require_signed(&Wrapping(-42));
219-
// }
212+
#[test]
213+
fn signed_wrapping_is_signed() {
214+
fn require_signed<T: Signed>(_: &T) {}
215+
require_signed(&Wrapping(-42));
216+
}

0 commit comments

Comments
 (0)