Move int and uint overflow tests into macros

This commit is contained in:
Brendan Zabarauskas 2014-01-30 23:55:34 +11:00
parent 1388c053a8
commit 1f15d24243
4 changed files with 14 additions and 15 deletions

View File

@ -120,10 +120,3 @@ impl CheckedMul for int {
}
}
}
#[test]
fn test_overflows() {
assert!((::int::MAX > 0));
assert!((::int::MIN <= 0));
assert!((::int::MIN + ::int::MAX + 1 == 0));
}

View File

@ -445,6 +445,13 @@ mod tests {
use num::CheckedDiv;
use num::Bitwise;
#[test]
fn test_overflows() {
assert!(MAX > 0);
assert!(MIN <= 0);
assert_eq!(MIN + MAX + 1, 0);
}
#[test]
fn test_num() {
num::test_num(10 as $T, 2 as $T);

View File

@ -90,11 +90,3 @@ impl CheckedMul for uint {
}
}
}
#[test]
fn test_overflows() {
use uint;
assert!((uint::MAX > 0u));
assert!((uint::MIN <= 0u));
assert!((uint::MIN + uint::MAX + 1u == 0u));
}

View File

@ -317,6 +317,13 @@ mod tests {
use num::Bitwise;
use u16;
#[test]
fn test_overflows() {
assert!(MAX > 0);
assert!(MIN <= 0);
assert_eq!(MIN + MAX + 1, 0);
}
#[test]
fn test_num() {
num::test_num(10 as $T, 2 as $T);