Skip to content

Commit 1f15d24

Browse files
committed
Move int and uint overflow tests into macros
1 parent 1388c05 commit 1f15d24

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

src/libstd/num/int.rs

-7
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,3 @@ impl CheckedMul for int {
120120
}
121121
}
122122
}
123-
124-
#[test]
125-
fn test_overflows() {
126-
assert!((::int::MAX > 0));
127-
assert!((::int::MIN <= 0));
128-
assert!((::int::MIN + ::int::MAX + 1 == 0));
129-
}

src/libstd/num/int_macros.rs

+7
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,13 @@ mod tests {
445445
use num::CheckedDiv;
446446
use num::Bitwise;
447447

448+
#[test]
449+
fn test_overflows() {
450+
assert!(MAX > 0);
451+
assert!(MIN <= 0);
452+
assert_eq!(MIN + MAX + 1, 0);
453+
}
454+
448455
#[test]
449456
fn test_num() {
450457
num::test_num(10 as $T, 2 as $T);

src/libstd/num/uint.rs

-8
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,3 @@ impl CheckedMul for uint {
9090
}
9191
}
9292
}
93-
94-
#[test]
95-
fn test_overflows() {
96-
use uint;
97-
assert!((uint::MAX > 0u));
98-
assert!((uint::MIN <= 0u));
99-
assert!((uint::MIN + uint::MAX + 1u == 0u));
100-
}

src/libstd/num/uint_macros.rs

+7
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,13 @@ mod tests {
317317
use num::Bitwise;
318318
use u16;
319319

320+
#[test]
321+
fn test_overflows() {
322+
assert!(MAX > 0);
323+
assert!(MIN <= 0);
324+
assert_eq!(MIN + MAX + 1, 0);
325+
}
326+
320327
#[test]
321328
fn test_num() {
322329
num::test_num(10 as $T, 2 as $T);

0 commit comments

Comments
 (0)